Skip to content

Commit ae27ed5

Browse files
Sync mock
1 parent dcf0aff commit ae27ed5

File tree

1 file changed

+9
-11
lines changed
  • pallets/transaction-storage/src

1 file changed

+9
-11
lines changed

pallets/transaction-storage/src/mock.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,13 @@ pub fn new_test_ext() -> TestExternalities {
8181
t.into()
8282
}
8383

84-
pub fn run_to_block(n: u64, f: impl Fn() -> Option<TransactionStorageProof>) {
85-
while System::block_number() < n {
86-
if let Some(proof) = f() {
87-
TransactionStorage::check_proof(RuntimeOrigin::none(), proof).unwrap();
88-
}
89-
TransactionStorage::on_finalize(System::block_number());
90-
System::on_finalize(System::block_number());
91-
System::set_block_number(System::block_number() + 1);
92-
System::on_initialize(System::block_number());
93-
TransactionStorage::on_initialize(System::block_number());
94-
}
84+
pub fn run_to_block(n: u64, f: impl Fn() -> Option<TransactionStorageProof> + 'static) {
85+
System::run_to_block_with::<AllPalletsWithSystem>(
86+
n,
87+
RunToBlockHooks::default().before_finalize(|_| {
88+
if let Some(proof) = f() {
89+
TransactionStorage::check_proof(RuntimeOrigin::none(), proof).unwrap();
90+
}
91+
}),
92+
);
9593
}

0 commit comments

Comments
 (0)