Skip to content

Commit

Permalink
Merge pull request #183 from readlnh/develop
Browse files Browse the repository at this point in the history
Inflation Test
  • Loading branch information
hackfisher committed Dec 30, 2019
2 parents 9e7f71c + 5b549ba commit 3c6d0be
Show file tree
Hide file tree
Showing 3 changed files with 275 additions and 242 deletions.
4 changes: 2 additions & 2 deletions srml/staking/src/inflation.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rstd::convert::TryInto;
use sr_primitives::{
traits::{IntegerSquareRoot, SaturatedConversion},
Perbill,
Perbill, Perquintill,
};
use substrate_primitives::U256;

Expand All @@ -20,7 +20,7 @@ pub fn compute_total_payout<T: Trait>(

let year: u32 = (living_time / MILLISECONDS_PER_YEAR + 1).saturated_into::<u32>();

let portion = Perbill::from_rational_approximation(era_duration, MILLISECONDS_PER_YEAR);
let portion = Perquintill::from_rational_approximation(era_duration, MILLISECONDS_PER_YEAR);

let maximum = portion * total_left;

Expand Down
15 changes: 7 additions & 8 deletions srml/staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,15 +480,14 @@ pub fn start_era(era_index: EraIndex) {
assert_eq!(Staking::current_era(), era_index);
}

// TODO

pub fn current_total_payout_for_duration(duration: u64) -> Balance {
// inflation::compute_total_payout(
// era_duration.saturated_into::<Moment>(),
// (<Module<Test>>::Time::now() - <Module<Test>>::GenesisTime::get()).saturated_into::<Moment>(),
// (<Module<Test>>::Cap::get() - Ring::total_issuance()).saturated_into::<Balance>(),
// )
// .0
unimplemented!()
inflation::compute_total_payout::<Test>(
duration.saturated_into::<Moment>(),
(Timestamp::now() - <mock::Test as Trait>::GenesisTime::get()).saturated_into::<Moment>(),
(<mock::Test as Trait>::Cap::get() - Ring::total_issuance()).saturated_into::<Balance>(),
Perbill::from_percent(50)
).0
}

pub fn reward_all_elected() {
Expand Down
Loading

0 comments on commit 3c6d0be

Please sign in to comment.