referrerpolicy=no-referrer-when-downgrade

pallet_parameters/
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//! Parameters pallet benchmarking.
19
20#![cfg(feature = "runtime-benchmarks")]
21
22use super::*;
23#[cfg(test)]
24use crate::Pallet as Parameters;
25
26use frame_benchmarking::v2::*;
27
28#[benchmarks(where T::RuntimeParameters: Default)]
29mod benchmarks {
30	use super::*;
31
32	#[benchmark]
33	fn set_parameter() -> Result<(), BenchmarkError> {
34		let kv = T::RuntimeParameters::default();
35		let k = kv.clone().into_parts().0;
36
37		let origin =
38			T::AdminOrigin::try_successful_origin(&k).map_err(|_| BenchmarkError::Weightless)?;
39
40		#[extrinsic_call]
41		_(origin as T::RuntimeOrigin, kv);
42
43		Ok(())
44	}
45
46	impl_benchmark_test_suite! {
47		Parameters,
48		crate::tests::mock::new_test_ext(),
49		crate::tests::mock::Runtime,
50	}
51}