Skip to content

Commit 6ef884d

Browse files
paritytech-release-backport-bot[bot]tmpolaczykgithub-actions[bot]bkchr
authored
[stable2409] Backport #8694 (#9028)
Backport #8694 into `stable2409` 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 <[email protected]> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Bastian Köcher <[email protected]>
1 parent e6225eb commit 6ef884d

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
@@ -23,6 +23,10 @@ use frame_benchmarking::{v2::*, BenchmarkError};
2323
use frame_system::{Pallet as System, RawOrigin};
2424
use sp_runtime::traits::One;
2525

26+
fn assert_has_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
27+
frame_system::Pallet::<T>::assert_has_event(generic_event.into());
28+
}
29+
2630
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
2731
frame_system::Pallet::<T>::assert_last_event(generic_event.into());
2832
}
@@ -149,7 +153,7 @@ mod benches {
149153
Pallet::<T>::exec_migration(c, false, &mut meter);
150154
}
151155

152-
assert_last_event::<T>(Event::UpgradeFailed {}.into());
156+
assert_has_event::<T>(Event::UpgradeFailed {}.into());
153157

154158
Ok(())
155159
}

0 commit comments

Comments
 (0)