From b410010ec4c9bc05410b62ebbba2a39d68d18c99 Mon Sep 17 00:00:00 2001 From: emostov <32168567+emostov@users.noreply.github.com> Date: Thu, 17 Mar 2022 13:38:09 +0000 Subject: [PATCH] Improve test ext pool creation & fix some more tests --- frame/nomination-pools/src/mock.rs | 2 +- frame/nomination-pools/src/tests.rs | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/frame/nomination-pools/src/mock.rs b/frame/nomination-pools/src/mock.rs index 08ed41e58369b..6aa3227585ce3 100644 --- a/frame/nomination-pools/src/mock.rs +++ b/frame/nomination-pools/src/mock.rs @@ -221,7 +221,7 @@ impl ExtBuilder { ext.execute_with(|| { // make a pool let amount_to_bond = ::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::::get(); diff --git a/frame/nomination-pools/src/tests.rs b/frame/nomination-pools/src/tests.rs index b5dafe168ee51..84f3277218a40 100644 --- a/frame/nomination-pools/src/tests.rs +++ b/frame/nomination-pools/src/tests.rs @@ -37,14 +37,18 @@ fn test_setup_works() { ); assert_eq!( RewardPools::::get(last_pool).unwrap(), - RewardPool:: { balance: 0, points: 0.into(), total_earnings: 0 } + RewardPool:: { + balance: Balances::minimum_balance(), + points: 0.into(), + total_earnings: Balances::minimum_balance() + } ); assert_eq!( Delegators::::get(10).unwrap(), Delegator:: { pool_id: last_pool, points: 10, - reward_pool_total_earnings: 0, + reward_pool_total_earnings: Balances::minimum_balance(), unbonding_era: None } ) @@ -374,7 +378,7 @@ mod join { Delegator:: { pool_id: 1, points: 2, - reward_pool_total_earnings: 0, + reward_pool_total_earnings: Balances::minimum_balance(), unbonding_era: None } ); @@ -397,7 +401,7 @@ mod join { Delegator:: { pool_id: 1, points: 24, - reward_pool_total_earnings: 0, + reward_pool_total_earnings: Balances::minimum_balance(), unbonding_era: None } ); @@ -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::::insert( 1, @@ -2207,6 +2212,15 @@ mod create { MaxPools::::put(3); MaxDelegators::::put(1); + // Then + assert_noop!( + Pools::create(Origin::signed(11), 20, 11, 11, 11), + Error::::InsufficientFundsToCreate + ); + + // Given + Balances::make_free_balance_be(&11, Balances::minimum_balance() + 20); + // Then assert_noop!( Pools::create(Origin::signed(11), 20, 11, 11, 11),