Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inflation Test #183

Merged
merged 9 commits into from
Dec 30, 2019
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