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:
Shaun Wang
2021-05-13 00:17:03 +12:00
committed by GitHub
parent d89a01cd96
commit ad584733e9
18 changed files with 85 additions and 206 deletions
+12
View File
@@ -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() }