mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 18:57:57 +00:00
do not chill indirectly-slashed nominators (#4553)
* do not chill indirectly-slashed nominators * test nomination non-kick and vote ignoring behavior
This commit is contained in:
committed by
Gavin Wood
parent
82661cd2ce
commit
6a0e60c3a4
@@ -2531,7 +2531,6 @@ fn remove_multi_deferred() {
|
||||
&[Perbill::from_percent(10)],
|
||||
);
|
||||
|
||||
|
||||
on_offence_now(
|
||||
&[
|
||||
OffenceDetails {
|
||||
@@ -2557,3 +2556,42 @@ fn version_initialized() {
|
||||
assert_eq!(<Staking as Store>::StorageVersion::get(), crate::migration::CURRENT_VERSION);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn slash_kicks_validators_not_nominators() {
|
||||
ExtBuilder::default().build().execute_with(|| {
|
||||
start_era(1);
|
||||
|
||||
assert_eq!(Balances::free_balance(&11), 1000);
|
||||
|
||||
let exposure = Staking::stakers(&11);
|
||||
assert_eq!(Balances::free_balance(&101), 2000);
|
||||
let nominated_value = exposure.others.iter().find(|o| o.who == 101).unwrap().value;
|
||||
|
||||
on_offence_now(
|
||||
&[
|
||||
OffenceDetails {
|
||||
offender: (11, exposure.clone()),
|
||||
reporters: vec![],
|
||||
},
|
||||
],
|
||||
&[Perbill::from_percent(10)],
|
||||
);
|
||||
|
||||
assert_eq!(Balances::free_balance(&11), 900);
|
||||
assert_eq!(Balances::free_balance(&101), 2000 - (nominated_value / 10));
|
||||
|
||||
// This is the best way to check that the validator was chilled; `get` will
|
||||
// return default value.
|
||||
for (stash, _) in <Staking as Store>::Validators::enumerate() {
|
||||
assert!(stash != 11);
|
||||
}
|
||||
|
||||
let nominations = <Staking as Store>::Nominators::get(&101).unwrap();
|
||||
|
||||
// and make sure that the vote will be ignored even if the validator
|
||||
// re-registers.
|
||||
let last_slash = <Staking as Store>::SlashingSpans::get(&11).unwrap().last_start();
|
||||
assert!(nominations.submitted_in < last_slash);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user