mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 00:31:02 +00:00
offences: make fn slash_fraction non-static (#11956)
* offences: make fn slash_fraction non-static * Bastifmt (inline variable)
This commit is contained in:
@@ -36,22 +36,24 @@ use sp_runtime::{
|
||||
|
||||
#[test]
|
||||
fn test_unresponsiveness_slash_fraction() {
|
||||
let dummy_offence =
|
||||
UnresponsivenessOffence { session_index: 0, validator_set_count: 50, offenders: vec![()] };
|
||||
// A single case of unresponsiveness is not slashed.
|
||||
assert_eq!(UnresponsivenessOffence::<()>::slash_fraction(1, 50), Perbill::zero());
|
||||
assert_eq!(dummy_offence.slash_fraction(1), Perbill::zero());
|
||||
|
||||
assert_eq!(
|
||||
UnresponsivenessOffence::<()>::slash_fraction(5, 50),
|
||||
dummy_offence.slash_fraction(5),
|
||||
Perbill::zero(), // 0%
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
UnresponsivenessOffence::<()>::slash_fraction(7, 50),
|
||||
dummy_offence.slash_fraction(7),
|
||||
Perbill::from_parts(4200000), // 0.42%
|
||||
);
|
||||
|
||||
// One third offline should be punished around 5%.
|
||||
assert_eq!(
|
||||
UnresponsivenessOffence::<()>::slash_fraction(17, 50),
|
||||
dummy_offence.slash_fraction(17),
|
||||
Perbill::from_parts(46200000), // 4.62%
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user