Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
run benchmarks for pallet-bridge-grandpa mock runtime
  • Loading branch information
svyatonik committed Mar 27, 2023
commit 04b428b04aeef53c24c9f1236f447b71b5112c09
2 changes: 2 additions & 0 deletions modules/grandpa/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,6 @@ benchmarks_instance_pallet! {
// check that the header#0 has been pruned
assert!(!<ImportedHeaders<T, I>>::contains_key(genesis_header.hash()));
}

impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::TestRuntime)
}
9 changes: 8 additions & 1 deletion modules/grandpa/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,17 @@ impl ChainWithGrandpa for TestBridgedChain {
const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = 64;
}

/// Return test extenalities to use in tests.
pub fn new_test_ext() -> sp_io::TestExternalities {
sp_io::TestExternalities::new(Default::default())
}

/// Return test within defaul test externalities context.
pub fn run_test<T>(test: impl FnOnce() -> T) -> T {
sp_io::TestExternalities::new(Default::default()).execute_with(test)
new_test_ext().execute_with(test)
}

/// Return test header with given number.
pub fn test_header(num: TestNumber) -> TestHeader {
// We wrap the call to avoid explicit type annotations in our tests
bp_test_utils::test_header(num)
Expand Down