Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Better sanity checks for nomination pools #11042

Merged
merged 3 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions frame/nomination-pools/benchmarking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl<T: Config> ListScenario<T> {
self.origin1_delegator = Some(joiner.clone());
CurrencyOf::<T>::make_free_balance_be(&joiner, amount * 2u32.into());

let original_bonded = T::StakingInterface::bonded_balance(&self.origin1).unwrap();
let original_bonded = T::StakingInterface::active_stake(&self.origin1).unwrap();

// Unbond `amount` from the underlying pool account so when the delegator joins
// we will maintain `current_bonded`.
Expand Down Expand Up @@ -206,7 +206,7 @@ frame_benchmarking::benchmarks! {
// setup the worst case list scenario.
let scenario = ListScenario::<T>::new(origin_weight, true)?;
assert_eq!(
T::StakingInterface::bonded_balance(&scenario.origin1).unwrap(),
T::StakingInterface::active_stake(&scenario.origin1).unwrap(),
origin_weight
);

Expand All @@ -221,7 +221,7 @@ frame_benchmarking::benchmarks! {
verify {
assert_eq!(CurrencyOf::<T>::free_balance(&joiner), joiner_free - max_additional);
assert_eq!(
T::StakingInterface::bonded_balance(&scenario.origin1).unwrap(),
T::StakingInterface::active_stake(&scenario.origin1).unwrap(),
scenario.dest_weight
);
}
Expand Down Expand Up @@ -273,7 +273,7 @@ frame_benchmarking::benchmarks! {
whitelist_account!(delegator_id);
}: _(Origin::Signed(delegator_id.clone()), delegator_id.clone())
verify {
let bonded_after = T::StakingInterface::bonded_balance(&scenario.origin1).unwrap();
let bonded_after = T::StakingInterface::active_stake(&scenario.origin1).unwrap();
// We at least went down to the destination bag, (if not an even lower bag)
assert!(bonded_after <= scenario.dest_weight.clone());
let delegator = Delegators::<T>::get(
Expand All @@ -300,7 +300,7 @@ frame_benchmarking::benchmarks! {

// Sanity check join worked
assert_eq!(
T::StakingInterface::bonded_balance(&pool_account).unwrap(),
T::StakingInterface::active_stake(&pool_account).unwrap(),
min_create_bond + min_join_bond
);
assert_eq!(CurrencyOf::<T>::free_balance(&joiner), min_join_bond);
Expand All @@ -310,7 +310,7 @@ frame_benchmarking::benchmarks! {

// Sanity check that unbond worked
assert_eq!(
T::StakingInterface::bonded_balance(&pool_account).unwrap(),
T::StakingInterface::active_stake(&pool_account).unwrap(),
min_create_bond
);
assert_eq!(pallet_staking::Ledger::<T>::get(&pool_account).unwrap().unlocking.len(), 1);
Expand Down Expand Up @@ -345,7 +345,7 @@ frame_benchmarking::benchmarks! {

// Sanity check join worked
assert_eq!(
T::StakingInterface::bonded_balance(&pool_account).unwrap(),
T::StakingInterface::active_stake(&pool_account).unwrap(),
min_create_bond + min_join_bond
);
assert_eq!(CurrencyOf::<T>::free_balance(&joiner), min_join_bond);
Expand All @@ -356,7 +356,7 @@ frame_benchmarking::benchmarks! {

// Sanity check that unbond worked
assert_eq!(
T::StakingInterface::bonded_balance(&pool_account).unwrap(),
T::StakingInterface::active_stake(&pool_account).unwrap(),
min_create_bond
);
assert_eq!(pallet_staking::Ledger::<T>::get(&pool_account).unwrap().unlocking.len(), 1);
Expand Down Expand Up @@ -408,7 +408,7 @@ frame_benchmarking::benchmarks! {

// Sanity check that unbond worked
assert_eq!(
T::StakingInterface::bonded_balance(&pool_account).unwrap(),
T::StakingInterface::active_stake(&pool_account).unwrap(),
Zero::zero()
);
assert_eq!(
Expand Down Expand Up @@ -488,7 +488,7 @@ frame_benchmarking::benchmarks! {
}
);
assert_eq!(
T::StakingInterface::bonded_balance(&Pools::<T>::create_bonded_account(1)),
T::StakingInterface::active_balance(&Pools::<T>::create_bonded_account(1)),
Some(min_create_bond)
);
}
Expand Down Expand Up @@ -531,7 +531,7 @@ frame_benchmarking::benchmarks! {
}
);
assert_eq!(
T::StakingInterface::bonded_balance(&Pools::<T>::create_bonded_account(1)),
T::StakingInterface::active_stake(&Pools::<T>::create_bonded_account(1)),
Some(min_create_bond)
);
}
Expand Down
Loading