git.delta.rocks / unique-network / refs/commits / bce2cc1e9ab8

difftreelog

source

pallets/configuration/src/benchmarking.rs2.8 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! Benchmarking setup for pallet-configuration1819use super::*;20use frame_benchmarking::benchmarks;21use frame_system::{EventRecord, RawOrigin};22use frame_support::assert_ok;2324fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {25	let events = frame_system::Pallet::<T>::events();26	let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();27	// compare to the last event record28	let EventRecord { event, .. } = &events[events.len() - 1];29	assert_eq!(event, &system_event);30}3132benchmarks! {33	where_clause { where34		T: Config,35		T::Balance: From<u32>36	}3738	set_weight_to_fee_coefficient_override {39		let coeff: u64 = 999;40	}: {41		assert_ok!(42			<Pallet<T>>::set_weight_to_fee_coefficient_override(RawOrigin::Root.into(), Some(coeff))43		);44	}4546	set_min_gas_price_override {47		let coeff: u64 = 999;48	}: {49		assert_ok!(50			<Pallet<T>>::set_min_gas_price_override(RawOrigin::Root.into(), Some(coeff))51		);52	}5354	set_app_promotion_configuration_override {55		let configuration: AppPromotionConfiguration<T::BlockNumber> = Default::default();56	}: {57		assert_ok!(58			<Pallet<T>>::set_app_promotion_configuration_override(RawOrigin::Root.into(), configuration)59		);60	}6162	set_collator_selection_desired_collators {63		let max: u32 = 999;64	}: {65		assert_ok!(66			<Pallet<T>>::set_collator_selection_desired_collators(RawOrigin::Root.into(), Some(max))67		);68	}69	verify {70		assert_last_event::<T>(Event::NewDesiredCollators{desired_collators: Some(max)}.into());71	}7273	set_collator_selection_license_bond {74		let bond_cost: Option<T::Balance> = Some(1000u32.into());75	}: {76		assert_ok!(77			<Pallet<T>>::set_collator_selection_license_bond(RawOrigin::Root.into(), bond_cost)78		);79	}80	verify {81		assert_last_event::<T>(Event::NewCollatorLicenseBond{bond_cost}.into());82	}8384	set_collator_selection_kick_threshold {85		let threshold: Option<T::BlockNumber> = Some(900u32.into());86	}: {87		assert_ok!(88			<Pallet<T>>::set_collator_selection_kick_threshold(RawOrigin::Root.into(), threshold)89		);90	}91	verify {92		assert_last_event::<T>(Event::NewCollatorKickThreshold{length_in_blocks: threshold}.into());93	}94}