Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Add debug info in assert_has_event and assert_last_event #12979

Merged
merged 2 commits into from
Jan 22, 2023
Merged
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
15 changes: 13 additions & 2 deletions frame/system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1498,13 +1498,24 @@ impl<T: Config> Pallet<T> {
/// Assert the given `event` exists.
#[cfg(any(feature = "std", feature = "runtime-benchmarks", test))]
pub fn assert_has_event(event: T::RuntimeEvent) {
assert!(Self::events().iter().any(|record| record.event == event))
let events = Self::events();
assert!(
events.iter().any(|record| record.event == event),
"expected event {:?} not found in events {:?}",
event,
events
zjb0807 marked this conversation as resolved.
Show resolved Hide resolved
);
}

/// Assert the last event equal to the given `event`.
#[cfg(any(feature = "std", feature = "runtime-benchmarks", test))]
pub fn assert_last_event(event: T::RuntimeEvent) {
assert_eq!(Self::events().last().expect("events expected").event, event);
let last_event = Self::events().last().expect("events expected").event.clone();
assert_eq!(
last_event, event,
"expected event {:?} is not equal to the last event {:?}",
event, last_event
zjb0807 marked this conversation as resolved.
Show resolved Hide resolved
);
}

/// Return the chain's current runtime version.
Expand Down