Skip to content

Commit d9ccb91

Browse files
committed
Fix the failing staking tests
1 parent 781e565 commit d9ccb91

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

substrate/frame/staking/src/tests.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -2573,8 +2573,8 @@ fn slashing_performed_according_exposure() {
25732573
// Handle an offence with a historical exposure.
25742574
on_offence_now(&[offence_from(11, None)], &[Perbill::from_percent(50)]);
25752575

2576-
// The stash account should be slashed for 250 (50% of 500).
2577-
assert_eq!(asset::stakeable_balance::<Test>(&11), 1000 - 250);
2576+
// The stash account should be slashed for 500 (50% of 1000).
2577+
assert_eq!(asset::stakeable_balance::<Test>(&11), 500);
25782578
});
25792579
}
25802580

@@ -2660,14 +2660,14 @@ fn subsequent_reports_in_same_span_pay_out_less() {
26602660

26612661
assert_eq!(Staking::eras_stakers(active_era(), &11).total, initial_balance);
26622662

2663-
on_offence_now(&[offence_from(11, None)], &[Perbill::from_percent(20)]);
2663+
on_offence_now(&[offence_from(11, Some(vec![1]))], &[Perbill::from_percent(20)]);
26642664

26652665
// F1 * (reward_proportion * slash - 0)
26662666
// 50% * (10% * initial_balance * 20%)
26672667
let reward = (initial_balance / 5) / 20;
26682668
assert_eq!(asset::total_balance::<Test>(&1), 10 + reward);
26692669

2670-
on_offence_now(&[offence_from(11, None)], &[Perbill::from_percent(50)]);
2670+
on_offence_now(&[offence_from(11, Some(vec![1]))], &[Perbill::from_percent(50)]);
26712671

26722672
let prior_payout = reward;
26732673

@@ -4669,10 +4669,12 @@ fn offences_weight_calculated_correctly() {
46694669
zero_offence_weight
46704670
);
46714671

4672-
// On Offence with N offenders, Unapplied: 4 Reads, 1 Write + 4 Reads, 5 Writes
4672+
// On Offence with N offenders, Unapplied: 4 Reads, 1 Write + 4 Reads, 5 Writes, 2 Reads + 2
4673+
// Writes for `SessionInterface::report_offence` call.
46734674
let n_offence_unapplied_weight = <Test as frame_system::Config>::DbWeight::get()
46744675
.reads_writes(4, 1) +
4675-
<Test as frame_system::Config>::DbWeight::get().reads_writes(4, 5);
4676+
<Test as frame_system::Config>::DbWeight::get().reads_writes(4, 5) +
4677+
<Test as frame_system::Config>::DbWeight::get().reads_writes(2, 2);
46764678

46774679
let offenders: Vec<
46784680
OffenceDetails<
@@ -4709,7 +4711,8 @@ fn offences_weight_calculated_correctly() {
47094711
+ <Test as frame_system::Config>::DbWeight::get().reads_writes(6, 5)
47104712
// `reward_cost` * reporters (1)
47114713
+ <Test as frame_system::Config>::DbWeight::get().reads_writes(2, 2)
4712-
;
4714+
// `SessionInterface::report_offence`
4715+
+ <Test as frame_system::Config>::DbWeight::get().reads_writes(2, 2);
47134716

47144717
assert_eq!(
47154718
<Staking as OnOffenceHandler<_, _, _>>::on_offence(

0 commit comments

Comments
 (0)