Rename ensure_free_balance_is to make_free_balance_be (#2092)

This commit is contained in:
Gav Wood
2019-03-23 11:18:14 +01:00
committed by GitHub
parent ce32bfa923
commit 91c7c7188d
4 changed files with 20 additions and 20 deletions
+16 -16
View File
@@ -105,7 +105,7 @@ fn invulnerability_should_work() {
// Make account 11 invulnerable
assert_ok!(Staking::set_invulnerables(vec![11]));
// Give account 11 some funds
let _ = Balances::ensure_free_balance_is(&11, 70);
let _ = Balances::make_free_balance_be(&11, 70);
// There is no slash grace -- slash immediately.
assert_eq!(Staking::offline_slash_grace(), 0);
// Account 11 has not been slashed
@@ -134,7 +134,7 @@ fn offline_should_slash_and_kick() {
// Test that an offline validator gets slashed and kicked
with_externalities(&mut ExtBuilder::default().build(), || {
// Give account 10 some balance
let _ = Balances::ensure_free_balance_is(&11, 1000);
let _ = Balances::make_free_balance_be(&11, 1000);
// Confirm account 10 is a validator
assert!(<Validators<Test>>::exists(&11));
// Validators get slashed immediately
@@ -164,7 +164,7 @@ fn offline_grace_should_delay_slashing() {
// Tests that with grace, slashing is delayed
with_externalities(&mut ExtBuilder::default().build(), || {
// Initialize account 10 with balance
let _ = Balances::ensure_free_balance_is(&11, 70);
let _ = Balances::make_free_balance_be(&11, 70);
// Verify account 11 has balance
assert_eq!(Balances::free_balance(&11), 70);
@@ -205,8 +205,8 @@ fn max_unstake_threshold_works() {
with_externalities(&mut ExtBuilder::default().build(), || {
const MAX_UNSTAKE_THRESHOLD: u32 = 10;
// Two users with maximum possible balance
let _ = Balances::ensure_free_balance_is(&11, u64::max_value());
let _ = Balances::ensure_free_balance_is(&21, u64::max_value());
let _ = Balances::make_free_balance_be(&11, u64::max_value());
let _ = Balances::make_free_balance_be(&21, u64::max_value());
// Give them full exposure as a staker
<Stakers<Test>>::insert(&11, Exposure { total: 1000000, own: 1000000, others: vec![]});
@@ -301,7 +301,7 @@ fn rewards_should_work() {
// check the balance of a validator accounts.
assert_eq!(Balances::total_balance(&11), 1000);
// and the nominator (to-be)
let _ = Balances::ensure_free_balance_is(&2, 500);
let _ = Balances::make_free_balance_be(&2, 500);
assert_eq!(Balances::total_balance(&2), 500);
// add a dummy nominator.
@@ -446,7 +446,7 @@ fn staking_should_work() {
assert_eq!(Staking::bonding_duration(), 2);
// put some money in account that we'll use.
for i in 1..5 { let _ = Balances::ensure_free_balance_is(&i, 2000); }
for i in 1..5 { let _ = Balances::make_free_balance_be(&i, 2000); }
// --- Block 1:
System::set_block_number(1);
@@ -635,7 +635,7 @@ fn nominating_and_rewards_should_work() {
// give the man some money
let initial_balance = 1000;
for i in [1, 2, 3, 4, 5, 10, 11, 20, 21].iter() {
let _ = Balances::ensure_free_balance_is(i, initial_balance);
let _ = Balances::make_free_balance_be(i, initial_balance);
}
// record their balances.
@@ -719,7 +719,7 @@ fn nominators_also_get_slashed() {
// give the man some money.
let initial_balance = 1000;
for i in [1, 2, 3, 10].iter() {
let _ = Balances::ensure_free_balance_is(i, initial_balance);
let _ = Balances::make_free_balance_be(i, initial_balance);
}
// 2 will nominate for 10
@@ -879,7 +879,7 @@ fn cannot_transfer_staked_balance() {
assert_noop!(Balances::transfer(Origin::signed(11), 20, 1), "account liquidity restrictions prevent withdrawal");
// Give account 11 extra free balance
let _ = Balances::ensure_free_balance_is(&11, 10000);
let _ = Balances::make_free_balance_be(&11, 10000);
// Confirm that account 11 can now transfer some balance
assert_ok!(Balances::transfer(Origin::signed(11), 20, 1));
});
@@ -921,7 +921,7 @@ fn cannot_reserve_staked_balance() {
assert_noop!(Balances::reserve(&11, 1), "account liquidity restrictions prevent withdrawal");
// Give account 11 extra free balance
let _ = Balances::ensure_free_balance_is(&11, 10000);
let _ = Balances::make_free_balance_be(&11, 10000);
// Confirm account 11 can now reserve balance
assert_ok!(Balances::reserve(&11, 1));
});
@@ -1029,7 +1029,7 @@ fn validator_payment_prefs_work() {
// check the balance of a validator's stash accounts.
assert_eq!(Balances::total_balance(&11), validator_initial_balance);
// and the nominator (to-be)
let _ = Balances::ensure_free_balance_is(&2, 500);
let _ = Balances::make_free_balance_be(&2, 500);
// add a dummy nominator.
// NOTE: this nominator is being added 'manually', use '.nominate()' to do it realistically.
@@ -1101,7 +1101,7 @@ fn bond_extra_works() {
assert_eq!(Staking::ledger(&10), Some(StakingLedger { stash: 11, total: 1000, active: 1000, unlocking: vec![] }));
// Give account 11 some large free balance greater than total
let _ = Balances::ensure_free_balance_is(&11, 1000000);
let _ = Balances::make_free_balance_be(&11, 1000000);
// Call the bond_extra function from controller, add only 100
assert_ok!(Staking::bond_extra(Origin::signed(10), 100));
@@ -1134,7 +1134,7 @@ fn bond_extra_and_withdraw_unbonded_works() {
assert_ok!(Staking::set_bonding_duration(2));
// Give account 11 some large free balance greater than total
let _ = Balances::ensure_free_balance_is(&11, 1000000);
let _ = Balances::make_free_balance_be(&11, 1000000);
// Initial config should be correct
assert_eq!(Staking::sessions_per_era(), 1);
@@ -1232,8 +1232,8 @@ fn slot_stake_is_least_staked_validator_and_limits_maximum_punishment() {
assert_eq!(Staking::stakers(&21).total, 2000);
// Give the man some money.
let _ = Balances::ensure_free_balance_is(&10, 1000);
let _ = Balances::ensure_free_balance_is(&20, 1000);
let _ = Balances::make_free_balance_be(&10, 1000);
let _ = Balances::make_free_balance_be(&20, 1000);
// We confirm initialized slot_stake is this value
assert_eq!(Staking::slot_stake(), Staking::stakers(&11).total);