Skip to content

Commit

Permalink
Improve test ext pool creation & fix some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
emostov committed Mar 17, 2022
1 parent cdc2a32 commit b410010
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion frame/nomination-pools/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl ExtBuilder {
ext.execute_with(|| {
// make a pool
let amount_to_bond = <Runtime as pools::Config>::StakingInterface::minimum_bond();
Balances::make_free_balance_be(&10, amount_to_bond * 2);
Balances::make_free_balance_be(&10, amount_to_bond * 2 + Balances::minimum_balance());
assert_ok!(Pools::create(RawOrigin::Signed(10).into(), amount_to_bond, 900, 901, 902));

let last_pool = LastPoolId::<Runtime>::get();
Expand Down
22 changes: 18 additions & 4 deletions frame/nomination-pools/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@ fn test_setup_works() {
);
assert_eq!(
RewardPools::<Runtime>::get(last_pool).unwrap(),
RewardPool::<Runtime> { balance: 0, points: 0.into(), total_earnings: 0 }
RewardPool::<Runtime> {
balance: Balances::minimum_balance(),
points: 0.into(),
total_earnings: Balances::minimum_balance()
}
);
assert_eq!(
Delegators::<Runtime>::get(10).unwrap(),
Delegator::<Runtime> {
pool_id: last_pool,
points: 10,
reward_pool_total_earnings: 0,
reward_pool_total_earnings: Balances::minimum_balance(),
unbonding_era: None
}
)
Expand Down Expand Up @@ -374,7 +378,7 @@ mod join {
Delegator::<Runtime> {
pool_id: 1,
points: 2,
reward_pool_total_earnings: 0,
reward_pool_total_earnings: Balances::minimum_balance(),
unbonding_era: None
}
);
Expand All @@ -397,7 +401,7 @@ mod join {
Delegator::<Runtime> {
pool_id: 1,
points: 24,
reward_pool_total_earnings: 0,
reward_pool_total_earnings: Balances::minimum_balance(),
unbonding_era: None
}
);
Expand Down Expand Up @@ -1742,6 +1746,7 @@ mod withdraw_unbonded_other {
assert_ok!(Pools::unbond_other(Origin::signed(550), 550));
unsafe_set_state(1, PoolState::Destroying).unwrap();
assert_ok!(Pools::unbond_other(Origin::signed(10), 10));
assert_eq!(Balances::free_balance(&10), 10);

SubPoolsStorage::<Runtime>::insert(
1,
Expand Down Expand Up @@ -2207,6 +2212,15 @@ mod create {
MaxPools::<Runtime>::put(3);
MaxDelegators::<Runtime>::put(1);

// Then
assert_noop!(
Pools::create(Origin::signed(11), 20, 11, 11, 11),
Error::<Runtime>::InsufficientFundsToCreate
);

// Given
Balances::make_free_balance_be(&11, Balances::minimum_balance() + 20);

// Then
assert_noop!(
Pools::create(Origin::signed(11), 20, 11, 11, 11),
Expand Down

0 comments on commit b410010

Please sign in to comment.