mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-23 18:55:48 +00:00
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:
@@ -391,8 +391,8 @@ impl<T: Config> List<T> {
|
||||
///
|
||||
/// * there are no duplicate ids,
|
||||
/// * length of this list is in sync with `CounterForListNodes`,
|
||||
/// * and sanity-checks all bags. This will cascade down all the checks and makes sure all bags
|
||||
/// are checked per *any* update to `List`.
|
||||
/// * and sanity-checks all bags and nodes. This will cascade down all the checks and makes sure
|
||||
/// all bags and nodes are checked per *any* update to `List`.
|
||||
#[cfg(feature = "std")]
|
||||
pub(crate) fn sanity_check() -> Result<(), &'static str> {
|
||||
use frame_support::ensure;
|
||||
@@ -414,7 +414,6 @@ impl<T: Config> List<T> {
|
||||
let thresholds = T::BagThresholds::get().iter().copied();
|
||||
let thresholds: Vec<u64> = if thresholds.clone().last() == Some(VoteWeight::MAX) {
|
||||
// in the event that they included it, we don't need to make any changes
|
||||
// Box::new(thresholds.collect()
|
||||
thresholds.collect()
|
||||
} else {
|
||||
// otherwise, insert it here.
|
||||
@@ -774,10 +773,13 @@ impl<T: Config> Node<T> {
|
||||
"node does not exist in the expected bag"
|
||||
);
|
||||
|
||||
let non_terminal_check = !self.is_terminal() &&
|
||||
expected_bag.head.as_ref() != Some(id) &&
|
||||
expected_bag.tail.as_ref() != Some(id);
|
||||
let terminal_check =
|
||||
expected_bag.head.as_ref() == Some(id) || expected_bag.tail.as_ref() == Some(id);
|
||||
frame_support::ensure!(
|
||||
!self.is_terminal() ||
|
||||
expected_bag.head.as_ref() == Some(id) ||
|
||||
expected_bag.tail.as_ref() == Some(id),
|
||||
non_terminal_check || terminal_check,
|
||||
"a terminal node is neither its bag head or tail"
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user