diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index eaeb29139..c0fc5759a 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -344,10 +344,10 @@ parameter_types! { } #[cfg(feature = "runtime-benchmarks")] -pub struct BenchmarkHelper(sp_std::marker::PhantomData<(SC, ACC)>); +pub struct DAppStakingBenchmarkHelper(sp_std::marker::PhantomData<(SC, ACC)>); #[cfg(feature = "runtime-benchmarks")] impl pallet_dapp_staking_v3::BenchmarkHelper, AccountId> - for BenchmarkHelper, AccountId> + for DAppStakingBenchmarkHelper, AccountId> { fn get_smart_contract(id: u32) -> SmartContract { let id_bytes = id.to_le_bytes(); @@ -363,15 +363,6 @@ impl pallet_dapp_staking_v3::BenchmarkHelper, AccountId .expect("Must succeed in test/benchmark environment."); } } -#[cfg(feature = "runtime-benchmarks")] -impl orml_oracle::BenchmarkHelper> - for BenchmarkHelper -{ - fn get_currency_id_value_pairs() -> sp_runtime::BoundedVec<(CurrencyId, Price), ConstU32<2>> { - sp_runtime::BoundedVec::try_from(vec![(CurrencyId::ASTR, Price::from_rational(15, 100))]) - .expect("out of bounds") - } -} pub struct AccountCheck; impl DappStakingAccountCheck for AccountCheck { @@ -407,7 +398,7 @@ impl pallet_dapp_staking_v3::Config for Runtime { type RankingEnabled = ConstBool; type WeightInfo = weights::pallet_dapp_staking_v3::SubstrateWeight; #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = BenchmarkHelper, AccountId>; + type BenchmarkHelper = DAppStakingBenchmarkHelper, AccountId>; } pub struct InflationPayoutPerBlock; @@ -1108,6 +1099,19 @@ impl pallet_price_aggregator::Config for Runtime { type WeightInfo = pallet_price_aggregator::weights::SubstrateWeight; } +#[cfg(feature = "runtime-benchmarks")] +pub struct OracleBenchmarkHelper; +#[cfg(feature = "runtime-benchmarks")] +impl orml_oracle::BenchmarkHelper> for OracleBenchmarkHelper { + fn get_currency_id_value_pairs() -> sp_runtime::BoundedVec<(CurrencyId, Price), ConstU32<2>> { + sp_runtime::BoundedVec::try_from(vec![ + (CurrencyId::ASTR, Price::from_rational(15, 100)), + (CurrencyId::ASTR, Price::from_rational(15, 100)), + ]) + .expect("out of bounds") + } +} + parameter_types! { // Cannot specify `Root` so need to do it like this, unfortunately. pub RootOperatorAccountId: AccountId = AccountId::from([0xffu8; 32]); @@ -1121,6 +1125,9 @@ impl orml_oracle::Config for Runtime { type OracleKey = CurrencyId; type OracleValue = Price; type RootOperatorAccountId = RootOperatorAccountId; + #[cfg(feature = "runtime-benchmarks")] + type Members = OracleMembershipWrapper; + #[cfg(not(feature = "runtime-benchmarks"))] type Members = OracleMembership; type MaxHasDispatchedSize = ConstU32<8>; type WeightInfo = oracle_benchmarks::weights::SubstrateWeight; @@ -1129,7 +1136,7 @@ impl orml_oracle::Config for Runtime { #[cfg(not(feature = "runtime-benchmarks"))] type MaxFeedValues = ConstU32<1>; #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = BenchmarkHelper, AccountId>; + type BenchmarkHelper = OracleBenchmarkHelper; } impl pallet_membership::Config for Runtime { @@ -1146,6 +1153,24 @@ impl pallet_membership::Config for Runtime { type WeightInfo = pallet_membership::weights::SubstrateWeight; } +/// OracleMembership wrapper used by benchmarks +#[cfg(feature = "runtime-benchmarks")] +pub struct OracleMembershipWrapper; + +#[cfg(feature = "runtime-benchmarks")] +impl frame_support::traits::SortedMembers for OracleMembershipWrapper { + fn sorted_members() -> Vec { + OracleMembership::sorted_members() + } + + fn add(account: &AccountId) { + frame_support::assert_ok!(OracleMembership::add_member( + frame_system::RawOrigin::Root.into(), + account.to_owned().into() + )); + } +} + construct_runtime!( pub struct Runtime { diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index 5352d31ab..005fc1ebd 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -369,10 +369,10 @@ impl pallet_multisig::Config for Runtime { } #[cfg(feature = "runtime-benchmarks")] -pub struct BenchmarkHelper(sp_std::marker::PhantomData<(SC, ACC)>); +pub struct DAppStakingBenchmarkHelper(sp_std::marker::PhantomData<(SC, ACC)>); #[cfg(feature = "runtime-benchmarks")] impl pallet_dapp_staking_v3::BenchmarkHelper, AccountId> - for BenchmarkHelper, AccountId> + for DAppStakingBenchmarkHelper, AccountId> { fn get_smart_contract(id: u32) -> SmartContract { let id_bytes = id.to_le_bytes(); @@ -388,15 +388,6 @@ impl pallet_dapp_staking_v3::BenchmarkHelper, AccountId .expect("Must succeed in test/benchmark environment."); } } -#[cfg(feature = "runtime-benchmarks")] -impl orml_oracle::BenchmarkHelper> - for BenchmarkHelper -{ - fn get_currency_id_value_pairs() -> sp_runtime::BoundedVec<(CurrencyId, Price), ConstU32<2>> { - sp_runtime::BoundedVec::try_from(vec![(CurrencyId::ASTR, Price::from_rational(15, 100))]) - .expect("out of bounds") - } -} pub struct AccountCheck; impl DappStakingAccountCheck for AccountCheck { @@ -446,7 +437,7 @@ impl pallet_dapp_staking_v3::Config for Runtime { type RankingEnabled = ConstBool; type WeightInfo = weights::pallet_dapp_staking_v3::SubstrateWeight; #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = BenchmarkHelper, AccountId>; + type BenchmarkHelper = DAppStakingBenchmarkHelper, AccountId>; } pub struct InflationPayoutPerBlock; @@ -1109,6 +1100,19 @@ impl pallet_price_aggregator::Config for Runtime { type WeightInfo = pallet_price_aggregator::weights::SubstrateWeight; } +#[cfg(feature = "runtime-benchmarks")] +pub struct OracleBenchmarkHelper; +#[cfg(feature = "runtime-benchmarks")] +impl orml_oracle::BenchmarkHelper> for OracleBenchmarkHelper { + fn get_currency_id_value_pairs() -> sp_runtime::BoundedVec<(CurrencyId, Price), ConstU32<2>> { + sp_runtime::BoundedVec::try_from(vec![ + (CurrencyId::ASTR, Price::from_rational(15, 100)), + (CurrencyId::ASTR, Price::from_rational(15, 100)), + ]) + .expect("out of bounds") + } +} + parameter_types! { // Cannot specify `Root` so need to do it like this, unfortunately. pub RootOperatorAccountId: AccountId = AccountId::from([0xffu8; 32]); @@ -1122,6 +1126,9 @@ impl orml_oracle::Config for Runtime { type OracleKey = CurrencyId; type OracleValue = Price; type RootOperatorAccountId = RootOperatorAccountId; + #[cfg(feature = "runtime-benchmarks")] + type Members = OracleMembershipWrapper; + #[cfg(not(feature = "runtime-benchmarks"))] type Members = OracleMembership; type MaxHasDispatchedSize = ConstU32<8>; type WeightInfo = oracle_benchmarks::weights::SubstrateWeight; @@ -1130,7 +1137,7 @@ impl orml_oracle::Config for Runtime { #[cfg(not(feature = "runtime-benchmarks"))] type MaxFeedValues = ConstU32<1>; #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = BenchmarkHelper, AccountId>; + type BenchmarkHelper = OracleBenchmarkHelper; } impl pallet_membership::Config for Runtime { @@ -1147,6 +1154,24 @@ impl pallet_membership::Config for Runtime { type WeightInfo = pallet_membership::weights::SubstrateWeight; } +/// OracleMembership wrapper used by benchmarks +#[cfg(feature = "runtime-benchmarks")] +pub struct OracleMembershipWrapper; + +#[cfg(feature = "runtime-benchmarks")] +impl frame_support::traits::SortedMembers for OracleMembershipWrapper { + fn sorted_members() -> Vec { + OracleMembership::sorted_members() + } + + fn add(account: &AccountId) { + frame_support::assert_ok!(OracleMembership::add_member( + frame_system::RawOrigin::Root.into(), + account.to_owned().into() + )); + } +} + construct_runtime!( pub struct Runtime {