Skip to content

Commit

Permalink
[SQUASH ME] Asking question
Browse files Browse the repository at this point in the history
  • Loading branch information
yanganto committed Feb 26, 2020
1 parent 820d123 commit a1dd42c
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions frame/staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@ fn rewards_should_work() {
assert_eq!(Staking::current_era(), 1);
assert_eq!(Session::current_index(), 3);

// check reward is send
assert_ne!(Ring::total_balance(&2), init_balance_2);
assert_ne!(Ring::total_balance(&10), init_balance_10);

// TODO: check the reward is correct or not
// 11 validator has 2/3 of the total rewards and half half for it and its nominator
// assert_eq_error_rate!(Ring::total_balance(&2), init_balance_2 + total_payout / 3, 1);
Expand All @@ -370,35 +374,35 @@ fn multi_era_reward_should_work() {
// Set payee to controller
assert_ok!(Staking::set_payee(Origin::signed(10), RewardDestination::Controller));

////TODO: check pay out
//// Compute now as other parameter won't change
//let total_payout_0 = current_total_payout_for_duration(3000);
//assert!(total_payout_0 > 10); // Test is meaningfull if reward something
//<Module<Test>>::reward_by_ids(vec![(11, 1)]);
//TODO: check pay out
// Compute now as other parameter won't change
let total_payout_0 = current_total_payout_for_duration(3000);
assert!(total_payout_0 > 10); // Test is meaningfull if reward something
<Module<Test>>::reward_by_ids(vec![(11, 1)]);

//start_session(0);
//start_session(1);
//start_session(2);
//start_session(3);
start_session(0);
start_session(1);
start_session(2);
start_session(3);

//assert_eq!(Staking::current_era(), 1);
//assert_eq!(Ring::total_balance(&10), init_balance_10 + total_payout_0);
assert_eq!(Staking::current_era(), 1);
assert_eq!(Ring::total_balance(&10), init_balance_10 + total_payout_0);

//start_session(4);
start_session(4);

////TODO: check pay out
//let total_payout_1 = current_total_payout_for_duration(3000);
//assert!(total_payout_1 > 10); // Test is meaningfull if reward something
//<Module<Test>>::reward_by_ids(vec![(11, 101)]);
//TODO: check pay out
let total_payout_1 = current_total_payout_for_duration(3000);
assert!(total_payout_1 > 10); // Test is meaningfull if reward something
<Module<Test>>::reward_by_ids(vec![(11, 101)]);

//// new era is triggered here.
//start_session(5);
// new era is triggered here.
start_session(5);

//// pay time
//assert_eq!(
// Ring::total_balance(&10),
// init_balance_10 + total_payout_0 + total_payout_1
//);
// pay time
assert_eq!(
Ring::total_balance(&10),
init_balance_10 + total_payout_0 + total_payout_1
);
});
}

Expand Down

0 comments on commit a1dd42c

Please sign in to comment.