Run benchmarks for mock runtimes (#1996)

* run benchmarks for pallet-bridge-grandpa mock runtime

* run benchmarks for pallet-bridge-relayers mock runtime

* run benchmarks for pallet-bridge-parachains mock runtime

* run benchmarks for pallet-bridge-messages mock runtime

* test benchmarks on mockj runtimes from CI

* clippy and spelling
This commit is contained in:
Svyatoslav Nikolsky
2023-03-27 14:33:12 +03:00
committed by Bastian Köcher
parent 88fb2befa0
commit 068f6f648b
10 changed files with 130 additions and 18 deletions
+19 -3
View File
@@ -99,6 +99,18 @@ impl pallet_bridge_relayers::Config for TestRuntime {
type WeightInfo = ();
}
#[cfg(feature = "runtime-benchmarks")]
impl pallet_bridge_relayers::benchmarking::Config for TestRuntime {
fn prepare_environment(account_params: RewardsAccountParams, reward: Balance) {
use frame_support::traits::fungible::Mutate;
let rewards_account =
bp_relayers::PayRewardFromAccount::<Balances, AccountId>::rewards_account(
account_params,
);
Balances::mint_into(&rewards_account, reward).unwrap();
}
}
/// Message lane that we're using in tests.
pub const TEST_REWARDS_ACCOUNT_PARAMS: RewardsAccountParams =
RewardsAccountParams::new(LaneId([0, 0, 0, 0]), *b"test", RewardsAccountOwner::ThisChain);
@@ -127,9 +139,13 @@ impl PaymentProcedure<AccountId, Balance> for TestPaymentProcedure {
}
}
/// Return test externalities to use in tests.
pub fn new_test_ext() -> sp_io::TestExternalities {
let t = frame_system::GenesisConfig::default().build_storage::<TestRuntime>().unwrap();
sp_io::TestExternalities::new(t)
}
/// Run pallet test.
pub fn run_test<T>(test: impl FnOnce() -> T) -> T {
let t = frame_system::GenesisConfig::default().build_storage::<TestRuntime>().unwrap();
let mut ext = sp_io::TestExternalities::new(t);
ext.execute_with(test)
new_test_ext().execute_with(test)
}