Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
Optimize Staking Pool Management (#312)
Browse files Browse the repository at this point in the history
* reorder

* optimize: pool manage

* add: reward staked should increase pool

* update: test

* update: format
  • Loading branch information
AurevoirXavier authored Sep 25, 2020
1 parent 0d4d4e8 commit ea51257
Show file tree
Hide file tree
Showing 3 changed files with 358 additions and 326 deletions.
23 changes: 23 additions & 0 deletions frame/staking/src/darwinia_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,28 @@ fn pool_should_be_increased_and_decreased_correctly() {
assert_eq!(Staking::ring_pool(), ring_pool);
assert_eq!(Staking::kton_pool(), kton_pool);
});

ExtBuilder::default()
.has_stakers(false)
.build_and_execute(|| {
bond_validator(11, 10, StakingBalance::RingBalance(1000));
assert_ok!(Staking::set_payee(
Origin::signed(10),
RewardDestination::Staked
));

start_era(1);

Staking::reward_by_ids(vec![(11, 1)]);
let payout = current_total_payout_for_duration(3 * 1000);
assert!(payout > 100);

start_era(2);

let ring_pool = Staking::ring_pool();
assert_ok!(Staking::payout_stakers(Origin::signed(10), 11, 1));
assert_eq!(Staking::ring_pool(), payout + ring_pool);
});
}

#[test]
Expand All @@ -843,6 +865,7 @@ fn unbond_over_max_unbondings_chunks_should_fail() {

for ts in 0..MAX_UNLOCKING_CHUNKS {
Timestamp::set_timestamp(ts as u64);

assert_ok!(Staking::unbond(
Origin::signed(controller),
StakingBalance::RingBalance(1)
Expand Down
Loading

0 comments on commit ea51257

Please sign in to comment.