mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 12:17:58 +00:00
Staking: store last min-active-bond on-chain (#12889)
* Staking: store last min-active-bond on-chain Storing the `min-active-bond` onchain helps the UIs with minimal on-chain costs. Closes https://github.com/paritytech/substrate/issues/12746 * Avoid relying on sorting to set the * Addresses PR comments
This commit is contained in:
@@ -4463,6 +4463,32 @@ mod election_data_provider {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_minimum_active_stake_is_correct() {
|
||||
ExtBuilder::default()
|
||||
.nominate(false)
|
||||
.add_staker(61, 60, 2_000, StakerStatus::<AccountId>::Nominator(vec![21]))
|
||||
.add_staker(71, 70, 10, StakerStatus::<AccountId>::Nominator(vec![21]))
|
||||
.add_staker(81, 80, 50, StakerStatus::<AccountId>::Nominator(vec![21]))
|
||||
.build_and_execute(|| {
|
||||
assert_ok!(<Staking as ElectionDataProvider>::electing_voters(None));
|
||||
assert_eq!(MinimumActiveStake::<Test>::get(), 10);
|
||||
|
||||
// remove staker with lower bond by limiting the number of voters and check
|
||||
// `MinimumActiveStake` again after electing voters.
|
||||
assert_ok!(<Staking as ElectionDataProvider>::electing_voters(Some(5)));
|
||||
assert_eq!(MinimumActiveStake::<Test>::get(), 50);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_minimum_active_stake_zero_correct() {
|
||||
ExtBuilder::default().has_stakers(false).build_and_execute(|| {
|
||||
assert_ok!(<Staking as ElectionDataProvider>::electing_voters(None));
|
||||
assert_eq!(MinimumActiveStake::<Test>::get(), 0);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn voters_include_self_vote() {
|
||||
ExtBuilder::default().nominate(false).build_and_execute(|| {
|
||||
|
||||
Reference in New Issue
Block a user