mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 14:17:56 +00:00
Add debug info in assert_has_event and assert_last_event (#12979)
* improve debug info in assert_has_event and assert_last_event * Apply suggestions from code review Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -1503,13 +1503,21 @@ 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 {event:?} not found in events {events:?}",
|
||||
);
|
||||
}
|
||||
|
||||
/// 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 {event:?} is not equal to the last event {last_event:?}",
|
||||
);
|
||||
}
|
||||
|
||||
/// Return the chain's current runtime version.
|
||||
|
||||
Reference in New Issue
Block a user