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

Commit b410010

Browse files
committed
Improve test ext pool creation & fix some more tests
1 parent cdc2a32 commit b410010

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

frame/nomination-pools/src/mock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ impl ExtBuilder {
221221
ext.execute_with(|| {
222222
// make a pool
223223
let amount_to_bond = <Runtime as pools::Config>::StakingInterface::minimum_bond();
224-
Balances::make_free_balance_be(&10, amount_to_bond * 2);
224+
Balances::make_free_balance_be(&10, amount_to_bond * 2 + Balances::minimum_balance());
225225
assert_ok!(Pools::create(RawOrigin::Signed(10).into(), amount_to_bond, 900, 901, 902));
226226

227227
let last_pool = LastPoolId::<Runtime>::get();

frame/nomination-pools/src/tests.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,18 @@ fn test_setup_works() {
3737
);
3838
assert_eq!(
3939
RewardPools::<Runtime>::get(last_pool).unwrap(),
40-
RewardPool::<Runtime> { balance: 0, points: 0.into(), total_earnings: 0 }
40+
RewardPool::<Runtime> {
41+
balance: Balances::minimum_balance(),
42+
points: 0.into(),
43+
total_earnings: Balances::minimum_balance()
44+
}
4145
);
4246
assert_eq!(
4347
Delegators::<Runtime>::get(10).unwrap(),
4448
Delegator::<Runtime> {
4549
pool_id: last_pool,
4650
points: 10,
47-
reward_pool_total_earnings: 0,
51+
reward_pool_total_earnings: Balances::minimum_balance(),
4852
unbonding_era: None
4953
}
5054
)
@@ -374,7 +378,7 @@ mod join {
374378
Delegator::<Runtime> {
375379
pool_id: 1,
376380
points: 2,
377-
reward_pool_total_earnings: 0,
381+
reward_pool_total_earnings: Balances::minimum_balance(),
378382
unbonding_era: None
379383
}
380384
);
@@ -397,7 +401,7 @@ mod join {
397401
Delegator::<Runtime> {
398402
pool_id: 1,
399403
points: 24,
400-
reward_pool_total_earnings: 0,
404+
reward_pool_total_earnings: Balances::minimum_balance(),
401405
unbonding_era: None
402406
}
403407
);
@@ -1742,6 +1746,7 @@ mod withdraw_unbonded_other {
17421746
assert_ok!(Pools::unbond_other(Origin::signed(550), 550));
17431747
unsafe_set_state(1, PoolState::Destroying).unwrap();
17441748
assert_ok!(Pools::unbond_other(Origin::signed(10), 10));
1749+
assert_eq!(Balances::free_balance(&10), 10);
17451750

17461751
SubPoolsStorage::<Runtime>::insert(
17471752
1,
@@ -2207,6 +2212,15 @@ mod create {
22072212
MaxPools::<Runtime>::put(3);
22082213
MaxDelegators::<Runtime>::put(1);
22092214

2215+
// Then
2216+
assert_noop!(
2217+
Pools::create(Origin::signed(11), 20, 11, 11, 11),
2218+
Error::<Runtime>::InsufficientFundsToCreate
2219+
);
2220+
2221+
// Given
2222+
Balances::make_free_balance_be(&11, Balances::minimum_balance() + 20);
2223+
22102224
// Then
22112225
assert_noop!(
22122226
Pools::create(Origin::signed(11), 20, 11, 11, 11),

0 commit comments

Comments
 (0)