Skip to content

Commit 735fbfa

Browse files
committed
fmt
1 parent ef29f54 commit 735fbfa

File tree

3 files changed

+49
-29
lines changed

3 files changed

+49
-29
lines changed

pallets/inflation/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,9 +552,10 @@ pub mod pallet {
552552
let adjustment_factor = staked_ratio / config.ideal_staking_rate;
553553

554554
let adjustable_part = adjustment_factor * config.adjustable_staker_reward_pool_per_era;
555-
let staker_reward_pool = config.decay_factor * config
556-
.base_staker_reward_pool_per_era
557-
.saturating_add(adjustable_part);
555+
let staker_reward_pool = config.decay_factor
556+
* config
557+
.base_staker_reward_pool_per_era
558+
.saturating_add(adjustable_part);
558559
let dapp_reward_pool = config.decay_factor * config.dapp_reward_pool_per_era;
559560

560561
(staker_reward_pool, dapp_reward_pool)

pallets/inflation/src/migration.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ mod v2 {
4848
InflationParameters as InflationParametersV1,
4949
};
5050

51-
pub struct VersionMigrateV1ToV2<T, DecayRate, DecayFactor>(PhantomData<(T, DecayRate, DecayFactor)>);
51+
pub struct VersionMigrateV1ToV2<T, DecayRate, DecayFactor>(
52+
PhantomData<(T, DecayRate, DecayFactor)>,
53+
);
5254

53-
impl<T: Config, DecayRate: Get<Perquintill>, DecayFactor: Get<Perquintill>> UncheckedOnRuntimeUpgrade
54-
for VersionMigrateV1ToV2<T, DecayRate, DecayFactor>
55+
impl<T: Config, DecayRate: Get<Perquintill>, DecayFactor: Get<Perquintill>>
56+
UncheckedOnRuntimeUpgrade for VersionMigrateV1ToV2<T, DecayRate, DecayFactor>
5557
{
5658
fn on_runtime_upgrade() -> Weight {
5759
let decay_rate = DecayRate::get();
@@ -96,7 +98,7 @@ mod v2 {
9698
bonus_reward_pool_per_period: old_config.bonus_reward_pool_per_period,
9799
ideal_staking_rate: old_config.ideal_staking_rate,
98100
decay_rate,
99-
decay_factor
101+
decay_factor,
100102
}),
101103
_ => None,
102104
},

pallets/inflation/src/tests.rs

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,11 @@ fn inflation_recalculation_works() {
288288
new_config.recalculation_era,
289289
now + <Test as Config>::CycleConfiguration::eras_per_cycle()
290290
);
291-
assert_eq!(new_config.decay_factor, Perquintill::one(), "Default decay factor expected.");
291+
assert_eq!(
292+
new_config.decay_factor,
293+
Perquintill::one(),
294+
"Default decay factor expected."
295+
);
292296

293297
// Verify collator rewards are as expected
294298
assert!(
@@ -550,7 +554,10 @@ fn on_initialize_decay_and_payout_works() {
550554
fn set_decay_factor_works() {
551555
ExternalityBuilder::build().execute_with(|| {
552556
// Sanity Check
553-
assert_eq!(ActiveInflationConfig::<Test>::get().decay_factor, Perquintill::one());
557+
assert_eq!(
558+
ActiveInflationConfig::<Test>::get().decay_factor,
559+
Perquintill::one()
560+
);
554561

555562
assert_noop!(
556563
Inflation::force_set_decay_factor(RuntimeOrigin::signed(1), Perquintill::one()),
@@ -562,8 +569,16 @@ fn set_decay_factor_works() {
562569
RuntimeOrigin::root(),
563570
new_decay_factor
564571
));
565-
System::assert_last_event(Event::DecayFactorUpdated { decay_factor: new_decay_factor }.into());
566-
assert_eq!(ActiveInflationConfig::<Test>::get().decay_factor, new_decay_factor);
572+
System::assert_last_event(
573+
Event::DecayFactorUpdated {
574+
decay_factor: new_decay_factor,
575+
}
576+
.into(),
577+
);
578+
assert_eq!(
579+
ActiveInflationConfig::<Test>::get().decay_factor,
580+
new_decay_factor
581+
);
567582
})
568583
}
569584

@@ -595,26 +610,23 @@ fn force_readjust_config_with_decay_works() {
595610
let new_max_emission_from_config = new_config.collator_reward_per_block
596611
* Balance::from(<Test as Config>::CycleConfiguration::blocks_per_cycle())
597612
+ new_config.treasury_reward_per_block
598-
* Balance::from(<Test as Config>::CycleConfiguration::blocks_per_cycle())
613+
* Balance::from(<Test as Config>::CycleConfiguration::blocks_per_cycle())
599614
+ new_config.dapp_reward_pool_per_era
600-
* Balance::from(
601-
<Test as Config>::CycleConfiguration::build_and_earn_eras_per_cycle(),
602-
)
615+
* Balance::from(
616+
<Test as Config>::CycleConfiguration::build_and_earn_eras_per_cycle(),
617+
)
603618
+ new_config.base_staker_reward_pool_per_era
604-
* Balance::from(
605-
<Test as Config>::CycleConfiguration::build_and_earn_eras_per_cycle(),
606-
)
619+
* Balance::from(
620+
<Test as Config>::CycleConfiguration::build_and_earn_eras_per_cycle(),
621+
)
607622
+ new_config.adjustable_staker_reward_pool_per_era
608-
* Balance::from(
609-
<Test as Config>::CycleConfiguration::build_and_earn_eras_per_cycle(),
610-
)
623+
* Balance::from(
624+
<Test as Config>::CycleConfiguration::build_and_earn_eras_per_cycle(),
625+
)
611626
+ new_config.bonus_reward_pool_per_period
612-
* Balance::from(<Test as Config>::CycleConfiguration::periods_per_cycle());
627+
* Balance::from(<Test as Config>::CycleConfiguration::periods_per_cycle());
613628

614-
lenient_balance_assert_eq!(
615-
original_max_emission,
616-
new_max_emission_from_config
617-
);
629+
lenient_balance_assert_eq!(original_max_emission, new_max_emission_from_config);
618630
})
619631
}
620632

@@ -665,8 +677,14 @@ fn force_update_decay_rate_and_reset_factor_works() {
665677

666678
// Check updates
667679
let cfg_after = ActiveInflationConfig::<Test>::get();
668-
assert_eq!(cfg_after.decay_rate, new_decay_rate, "Decay rate should be reset to default");
669-
assert_eq!(cfg_after.decay_factor, new_decay_factor, "Decay factor should be updated");
680+
assert_eq!(
681+
cfg_after.decay_rate, new_decay_rate,
682+
"Decay rate should be reset to default"
683+
);
684+
assert_eq!(
685+
cfg_after.decay_factor, new_decay_factor,
686+
"Decay factor should be updated"
687+
);
670688

671689
let issuance_before = Balances::total_issuance();
672690
Inflation::on_initialize(1);
@@ -675,4 +693,3 @@ fn force_update_decay_rate_and_reset_factor_works() {
675693
lenient_balance_assert_eq!(issuance_now, issuance_before + total_expected_payout);
676694
});
677695
}
678-

0 commit comments

Comments
 (0)