git.delta.rocks / unique-network / refs/commits / 900be63a359f

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 frame_benchmarking::benchmarks;20use frame_support::assert_ok;21use frame_system::{pallet_prelude::*, EventRecord, RawOrigin};2223use super::*;2425fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {26	let events = frame_system::Pallet::<T>::events();27	let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();28	// compare to the last event record29	let EventRecord { event, .. } = &events[events.len() - 1];30	assert_eq!(event, &system_event);31}3233benchmarks! {34	where_clause { where35		T: Config,36		T::Balance: From<u32>37	}3839	set_weight_to_fee_coefficient_override {40		let coeff: u64 = 999;41	}: {42		assert_ok!(43			<Pallet<T>>::set_weight_to_fee_coefficient_override(RawOrigin::Root.into(), Some(coeff))44		);45	}4647	set_min_gas_price_override {48		let coeff: u64 = 999;49	}: {50		assert_ok!(51			<Pallet<T>>::set_min_gas_price_override(RawOrigin::Root.into(), Some(coeff))52		);53	}5455	set_app_promotion_configuration_override {56		let configuration: AppPromotionConfiguration<BlockNumberFor<T>> = Default::default();57	}: {58		assert_ok!(59			<Pallet<T>>::set_app_promotion_configuration_override(RawOrigin::Root.into(), configuration)60		);61	}6263	set_collator_selection_desired_collators {64		let max: u32 = 999;65	}: {66		assert_ok!(67			<Pallet<T>>::set_collator_selection_desired_collators(RawOrigin::Root.into(), Some(max))68		);69	}70	verify {71		assert_last_event::<T>(Event::NewDesiredCollators{desired_collators: Some(max)}.into());72	}7374	set_collator_selection_license_bond {75		let bond_cost: Option<T::Balance> = Some(1000u32.into());76	}: {77		assert_ok!(78			<Pallet<T>>::set_collator_selection_license_bond(RawOrigin::Root.into(), bond_cost)79		);80	}81	verify {82		assert_last_event::<T>(Event::NewCollatorLicenseBond{bond_cost}.into());83	}8485	set_collator_selection_kick_threshold {86		let threshold: Option<BlockNumberFor<T>> = Some(900u32.into());87	}: {88		assert_ok!(89			<Pallet<T>>::set_collator_selection_kick_threshold(RawOrigin::Root.into(), threshold)90		);91	}92	verify {93		assert_last_event::<T>(Event::NewCollatorKickThreshold{length_in_blocks: threshold}.into());94	}95}