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:
Ankan
2022-10-17 18:44:42 +02:00
committed by GitHub
parent bb175f0373
commit ca15fe7e3d
2 changed files with 7 additions and 106 deletions
+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()?;