Skip to content

Commit d30a5fb

Browse files
tmpolaczykgithub-actions[bot]bkchr
authored
Fix pallet_migrations benchmark when FailedMigrationHandler emits events (#8694)
When FailedMigrationHandler emits events, the `UpgradeFailed` event is not the last one, so `assert_last_event` fails. Fixed by checking that the `UpgradeFailed` event is emitted, even if it is not the last one. --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Bastian Köcher <git@kchr.de>
1 parent 0511431 commit d30a5fb

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

prdoc/pr_8694.prdoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
title: Fix pallet_migrations benchmark when FailedMigrationHandler emits events
2+
doc:
3+
- audience: Runtime Dev
4+
description: When FailedMigrationHandler emits events, the `UpgradeFailed` event
5+
is not the last one, so `assert_last_event` fails. Fixed by checking that the
6+
`UpgradeFailed` event is emitted, even if it is not the last one.
7+
crates:
8+
- name: pallet-migrations
9+
bump: patch

substrate/frame/migrations/src/benchmarking.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ use sp_core::{twox_128, Get};
2626
use sp_io::{storage, KillStorageResult};
2727
use sp_runtime::traits::One;
2828

29+
fn assert_has_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
30+
frame_system::Pallet::<T>::assert_has_event(generic_event.into());
31+
}
32+
2933
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
3034
frame_system::Pallet::<T>::assert_last_event(generic_event.into());
3135
}
@@ -152,7 +156,7 @@ mod benches {
152156
Pallet::<T>::exec_migration(c, false, &mut meter);
153157
}
154158

155-
assert_last_event::<T>(Event::UpgradeFailed {}.into());
159+
assert_has_event::<T>(Event::UpgradeFailed {}.into());
156160

157161
Ok(())
158162
}

0 commit comments

Comments
 (0)