Skip to content

Commit 41f5ddd

Browse files
paritytech-release-backport-bot[bot]tmpolaczykgithub-actions[bot]bkchrEgorPopelyaev
authored
[stable2503] Backport #8694 (#9030)
Backport #8694 into `stable2503` from tmpolaczyk. See the [documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md) on how to use this bot. <!-- # To be used by other automation, do not modify: original-pr-number: #${pull_number} --> Co-authored-by: tmpolaczyk <44604217+tmpolaczyk@users.noreply.github.com> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Egor_P <egor@parity.io>
1 parent d6d983b commit 41f5ddd

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

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)