Fuzzer for Pallet Bags List (#9851)

* Fuzzer for Pallet Bags List

* Some small updates

* Fuzzer for Pallet Bags List

This PR adds a fuzzer for the `SortedListProvider` API exposed by pallet-bags-list.

* Feature gate code NOT used by fuzz feature

* Create Enum for list actions

* fix some small mistakes

* try and make CI happy

* fmt

* Do not insert before updating

* clean up some misc. comments

* marginally improve Node::sanity_check

* Change ID_RANGE to 25_000

* comma

* try improve correct feature gating so no unused code

Co-authored-by: thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
Zeke Mostov
2021-10-31 22:10:13 +01:00
committed by GitHub
parent 47c7447106
commit 21c8d18c23
9 changed files with 144 additions and 10 deletions
+5 -2
View File
@@ -101,12 +101,13 @@ pub(crate) const GENESIS_IDS: [(AccountId, VoteWeight); 4] =
[(1, 10), (2, 1_000), (3, 1_000), (4, 1_000)];
#[derive(Default)]
pub(crate) struct ExtBuilder {
pub struct ExtBuilder {
ids: Vec<(AccountId, VoteWeight)>,
}
impl ExtBuilder {
/// Add some AccountIds to insert into `List`.
#[cfg(test)]
pub(crate) fn add_ids(mut self, ids: Vec<(AccountId, VoteWeight)>) -> Self {
self.ids = ids;
self
@@ -126,18 +127,20 @@ impl ExtBuilder {
ext
}
pub(crate) fn build_and_execute(self, test: impl FnOnce() -> ()) {
pub fn build_and_execute(self, test: impl FnOnce() -> ()) {
self.build().execute_with(|| {
test();
List::<Runtime>::sanity_check().expect("Sanity check post condition failed")
})
}
#[cfg(test)]
pub(crate) fn build_and_execute_no_post_check(self, test: impl FnOnce() -> ()) {
self.build().execute_with(test)
}
}
#[cfg(test)]
pub(crate) mod test_utils {
use super::*;
use list::Bag;