diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index a77d1ca31b50f..1e93f3889f2d8 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -1498,13 +1498,21 @@ impl Pallet { /// 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.