Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Shreevatsa N <i.mnshreevatsa@gmail.com>
  • Loading branch information
vatsa287 committed May 28, 2024
1 parent 5b218bf commit 70da3a1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ benchmarks_instance_pallet! {
));
} verify {
assert!(<Members<T, I>>::get().contains(&new_member));
#[cfg(test)] crate::tests::clean();
#[cfg(test)] crate::mock::clean();
}

// the case of no prime or the prime being removed is surely cheaper than the case of
Expand All @@ -78,7 +78,7 @@ benchmarks_instance_pallet! {
assert!(!<Members<T, I>>::get().contains(&to_remove));
// prime is rejigged
assert!(<Prime<T, I>>::get().is_some() && T::MembershipChanged::get_prime().is_some());
#[cfg(test)] crate::tests::clean();
#[cfg(test)] crate::mock::clean();
}

// we remove a non-prime to make sure it needs to be set again.
Expand All @@ -102,7 +102,7 @@ benchmarks_instance_pallet! {
assert!(<Members<T, I>>::get().contains(&add));
// prime is rejigged
assert!(<Prime<T, I>>::get().is_some() && T::MembershipChanged::get_prime().is_some());
#[cfg(test)] crate::tests::clean();
#[cfg(test)] crate::mock::clean();
}

// er keep the prime common between incoming and outgoing to make sure it is rejigged.
Expand All @@ -122,7 +122,7 @@ benchmarks_instance_pallet! {
assert_eq!(<Members<T, I>>::get(), new_members);
// prime is rejigged
assert!(<Prime<T, I>>::get().is_some() && T::MembershipChanged::get_prime().is_some());
#[cfg(test)] crate::tests::clean();
#[cfg(test)] crate::mock::clean();
}

change_key {
Expand All @@ -143,7 +143,7 @@ benchmarks_instance_pallet! {
assert!(<Members<T, I>>::get().contains(&add));
// prime is rejigged
assert_eq!(<Prime<T, I>>::get().unwrap(), add);
#[cfg(test)] crate::tests::clean();
#[cfg(test)] crate::mock::clean();
}

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

clear_prime {
Expand All @@ -174,8 +174,8 @@ benchmarks_instance_pallet! {
} verify {
assert!(<Prime<T, I>>::get().is_none());
assert!(<T::MembershipChanged>::get_prime().is_none());
#[cfg(test)] crate::tests::clean();
#[cfg(test)] crate::mock::clean();
}

impl_benchmark_test_suite!(Membership, crate::tests::new_bench_ext(), crate::tests::Test);
impl_benchmark_test_suite!(Membership, crate::mock::new_bench_ext(), crate::mock::Test);
}
9 changes: 9 additions & 0 deletions substrate/frame/membership/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ use sp_std::prelude::*;
pub mod migrations;
pub mod weights;

#[cfg(any(feature = "mock", test))]
pub mod mock;

#[cfg(feature = "runtime-benchmarks")]
pub mod benchmarking;

#[cfg(test)]
mod tests;

pub use pallet::*;
pub use weights::WeightInfo;

Expand Down

0 comments on commit 70da3a1

Please sign in to comment.