referrerpolicy=no-referrer-when-downgrade

pallet_accumulate_and_forward/
benchmarking.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// 	http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! Benchmarks for pallet-accumulate-and-forward.
19
20use super::*;
21use frame_benchmarking::v2::*;
22use frame_support::traits::fungible::Unbalanced;
23
24#[benchmarks]
25mod benchmarks {
26	use super::*;
27
28	/// Benchmark for [`Forwarder::forward`].
29	///
30	/// This measures the full cost of an accumulation-account-to-destination transfer.
31	#[benchmark]
32	fn send_native() {
33		let accumulation_account = Pallet::<T>::accumulation_account();
34		let ed = T::Currency::minimum_balance();
35		let amount = T::MinTransferAmount::get();
36
37		// Fund with ED (to keep account alive) plus the amount to be sent.
38		T::Currency::write_balance(&accumulation_account, ed + amount)
39			.expect("benchmark setup should succeed");
40
41		#[block]
42		{
43			let _ = T::Forwarder::forward(accumulation_account, amount);
44		}
45	}
46
47	impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(true), crate::mock::Test);
48}