git.delta.rocks / unique-network / refs/commits / 8cb94776e05e

difftreelog

source

pallets/configuration/src/benchmarking.rs3.1 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, BoundedVec, traits::Currency};23use xcm::v1::MultiLocation;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 { where T: Config }3536	set_weight_to_fee_coefficient_override {37		let coeff: u64 = 999;38	}: {39		assert_ok!(40			<Pallet<T>>::set_weight_to_fee_coefficient_override(RawOrigin::Root.into(), Some(coeff))41		);42	}4344	set_min_gas_price_override {45		let coeff: u64 = 999;46	}: {47		assert_ok!(48			<Pallet<T>>::set_min_gas_price_override(RawOrigin::Root.into(), Some(coeff))49		);50	}5152	set_xcm_allowed_locations {53		let locations: BoundedVec<MultiLocation, T::MaxXcmAllowedLocations> = Default::default();54	}: {55		assert_ok!(56			<Pallet<T>>::set_xcm_allowed_locations(RawOrigin::Root.into(), Some(locations))57		);58	}5960	set_app_promotion_configuration_override {61		let configuration: AppPromotionConfiguration<T::BlockNumber> = Default::default();62	}: {63		assert_ok!(64			<Pallet<T>>::set_app_promotion_configuration_override(RawOrigin::Root.into(), configuration)65		);66	}6768	set_collator_selection_desired_collators {69		let max: u32 = 999;70	}: {71		assert_ok!(72			<Pallet<T>>::set_collator_selection_desired_collators(RawOrigin::Root.into(), Some(max.clone()))73		);74	}75	verify {76		assert_last_event::<T>(Event::NewDesiredCollators{desired_collators: Some(max)}.into());77	}7879	set_collator_selection_license_bond {80		let bond_cost: Option<BalanceOf<T>> = Some(T::Currency::minimum_balance() * 10u32.into());81	}: {82		assert_ok!(83			<Pallet<T>>::set_collator_selection_license_bond(RawOrigin::Root.into(), bond_cost.clone())84		);85	}86	verify {87		assert_last_event::<T>(Event::NewCollatorLicenseBond{bond_cost}.into());88	}8990	set_collator_selection_kick_threshold {91		let threshold: Option<T::BlockNumber> = Some(900u32.into());92	}: {93		assert_ok!(94			<Pallet<T>>::set_collator_selection_kick_threshold(RawOrigin::Root.into(), threshold.clone())95		);96	}97	verify {98		assert_last_event::<T>(Event::NewCollatorKickThreshold{length_in_blocks: threshold}.into());99	}100}