staking: Fix Reward usage (#10887)

* staking: Fix `Reward` usage

* Some small fixes

* Check on_unbalanced was called

* Improve tests

* Add not for Reward; FMT

* 🤦

Co-authored-by: parity-processbot <>
This commit is contained in:
Zeke Mostov
2022-04-21 06:50:17 -07:00
committed by GitHub
parent 806f6cc683
commit 97f5193137
4 changed files with 50 additions and 6 deletions
+9 -1
View File
@@ -237,6 +237,7 @@ const THRESHOLDS: [sp_npos_elections::VoteWeight; 9] =
parameter_types! {
pub static BagThresholds: &'static [sp_npos_elections::VoteWeight] = &THRESHOLDS;
pub static MaxNominations: u32 = 16;
pub static RewardOnUnbalanceWasCalled: bool = false;
}
impl pallet_bags_list::Config for Test {
@@ -255,6 +256,13 @@ impl onchain::Config for OnChainSeqPhragmen {
type WeightInfo = ();
}
pub struct MockReward {}
impl OnUnbalanced<PositiveImbalanceOf<Test>> for MockReward {
fn on_unbalanced(_: PositiveImbalanceOf<Test>) {
RewardOnUnbalanceWasCalled::set(true);
}
}
impl crate::pallet::pallet::Config for Test {
type MaxNominations = MaxNominations;
type Currency = Balances;
@@ -263,7 +271,7 @@ impl crate::pallet::pallet::Config for Test {
type RewardRemainder = RewardRemainderMock;
type Event = Event;
type Slash = ();
type Reward = ();
type Reward = MockReward;
type SessionsPerEra = SessionsPerEra;
type SlashDeferDuration = SlashDeferDuration;
type SlashCancelOrigin = frame_system::EnsureRoot<Self::AccountId>;