mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 06:51:07 +00:00
frame system: add event util functions for tests. (#8734)
* frame system: add event util functions for tests. * URemove unused fn. * Apply review suggestions.
This commit is contained in:
@@ -1449,6 +1449,18 @@ impl<T: Config> Pallet<T> {
|
||||
<EventTopics<T>>::remove_all();
|
||||
}
|
||||
|
||||
/// Assert the given `event` exists.
|
||||
#[cfg(any(feature = "std", feature = "runtime-benchmarks", test))]
|
||||
pub fn assert_has_event(event: T::Event) {
|
||||
assert!(Self::events().iter().any(|record| record.event == event))
|
||||
}
|
||||
|
||||
/// Assert the last event equal to the given `event`.
|
||||
#[cfg(any(feature = "std", feature = "runtime-benchmarks", test))]
|
||||
pub fn assert_last_event(event: T::Event) {
|
||||
assert_eq!(Self::events().last().expect("events expected").event, event);
|
||||
}
|
||||
|
||||
/// Return the chain's current runtime version.
|
||||
pub fn runtime_version() -> RuntimeVersion { T::Version::get() }
|
||||
|
||||
|
||||
@@ -374,6 +374,17 @@ fn deposit_event_topics() {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn event_util_functions_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
System::set_block_number(1);
|
||||
System::deposit_event(SysEvent::CodeUpdated);
|
||||
|
||||
System::assert_has_event(SysEvent::CodeUpdated.into());
|
||||
System::assert_last_event(SysEvent::CodeUpdated.into());
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn prunes_block_hash_mappings() {
|
||||
new_test_ext().execute_with(|| {
|
||||
|
||||
Reference in New Issue
Block a user