Implements try_state hook in elections and EPM pallets (#13979)

* Adds try_state hook to elections pallets

* Addresses PR review comments

Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>

* remove unecessary println

* ensures try-runtime does not mutate storage

* Addresses PR comments

* Fixes snapshot invariant checks; simplifies test infra

---------

Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>
Co-authored-by: parity-processbot <>
This commit is contained in:
Gonçalo Pestana
2023-04-27 19:45:43 +01:00
committed by GitHub
parent b5201fa0ec
commit 82aa16315d
4 changed files with 223 additions and 45 deletions
@@ -615,7 +615,17 @@ impl ExtBuilder {
}
pub fn build_and_execute(self, test: impl FnOnce() -> ()) {
self.build().execute_with(test)
sp_tracing::try_init_simple();
let mut ext = self.build();
ext.execute_with(test);
#[cfg(feature = "try-runtime")]
ext.execute_with(|| {
assert_ok!(<MultiPhase as frame_support::traits::Hooks<u64>>::try_state(
System::block_number()
));
});
}
}