Skip to content

Commit

Permalink
pallet-membership: Do not verify the MembershipChanged in bechmarks (
Browse files Browse the repository at this point in the history
…#6439)

There is no need to verify in the `pallet-membership` benchmark that the
`MemembershipChanged` implementation works as the pallet thinks it
should work. If you for example set it to `()`, `get_prime()` will
always return `None`.

TLDR: Remove the checks of `MembershipChanged` in the benchmarks to
support any kind of implementation.

---------

Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: Adrian Catangiu <adrian@parity.io>
  • Loading branch information
3 people authored Nov 11, 2024
1 parent ace62f1 commit a5de3b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 10 additions & 0 deletions prdoc/pr_6439.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: 'pallet-membership: Do not verify the `MembershipChanged` in bechmarks'
doc:
- audience: Runtime Dev
description: |-
There is no need to verify in the `pallet-membership` benchmark that the `MemembershipChanged` implementation works as the pallet thinks it should work. If you for example set it to `()`, `get_prime()` will always return `None`.

TLDR: Remove the checks of `MembershipChanged` in the benchmarks to support any kind of implementation.
crates:
- name: pallet-membership
bump: patch
5 changes: 2 additions & 3 deletions substrate/frame/membership/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ benchmarks_instance_pallet! {
assert!(!Members::<T, I>::get().contains(&remove));
assert!(Members::<T, I>::get().contains(&add));
// prime is rejigged
assert!(Prime::<T, I>::get().is_some() && T::MembershipChanged::get_prime().is_some());
assert!(Prime::<T, I>::get().is_some());
#[cfg(test)] crate::mock::clean();
}

Expand All @@ -119,7 +119,7 @@ benchmarks_instance_pallet! {
new_members.sort();
assert_eq!(Members::<T, I>::get(), new_members);
// prime is rejigged
assert!(Prime::<T, I>::get().is_some() && T::MembershipChanged::get_prime().is_some());
assert!(Prime::<T, I>::get().is_some());
#[cfg(test)] crate::mock::clean();
}

Expand Down Expand Up @@ -157,7 +157,6 @@ benchmarks_instance_pallet! {
));
} verify {
assert!(Prime::<T, I>::get().is_some());
assert!(<T::MembershipChanged>::get_prime().is_some());
#[cfg(test)] crate::mock::clean();
}

Expand Down

0 comments on commit a5de3b1

Please sign in to comment.