Execute try-state at end of each test to ensure pallet data integrity (#12453)

* execute try-state at end of tests

* run post condition only with try runtime

* Revert "run post condition only with try runtime"

This reverts commit 7db0ecf7eaa2ee5afa5a995487b73d023ba3bcd9.

* voterlist contains validators as well

* fmt

* simplify

* fmt

Co-authored-by: parity-processbot <>
This commit is contained in:
Ankanandparity-processbot authored and GitHub committed 2022-10-17 17:44:42 +01:00
1 parent bb175f0373
commit ca15fe7e3d
2 files changed
+7 -106

No files matched your search

+3 -2
View File
@@ -1552,11 +1552,12 @@ impl<T: Config> StakingInterface for Pallet<T> {
}
}
#[cfg(feature = "try-runtime")]
#[cfg(any(test, feature = "try-runtime"))]
impl<T: Config> Pallet<T> {
pub(crate) fn do_try_state(_: BlockNumberFor<T>) -> Result<(), &'static str> {
ensure!(
T::VoterList::iter().all(|x| <Nominators<T>>::contains_key(&x)),
T::VoterList::iter()
.all(|x| <Nominators<T>>::contains_key(&x) || <Validators<T>>::contains_key(&x)),
"VoterList contains non-nominators"
);
T::VoterList::try_state()?;