Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
offences: fix babe benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
andresilva committed Jul 1, 2020
1 parent f88e5e6 commit 15b1000
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions frame/offences/benchmarking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,21 +323,16 @@ benchmarks! {
}

report_offence_babe {
let r in 1 .. MAX_REPORTERS;
let n in 0 .. MAX_NOMINATORS.min(MAX_NOMINATIONS as u32);
let o = 1;

// Make r reporters
let mut reporters = vec![];
for i in 0 .. r {
let reporter = account("reporter", i, SEED);
reporters.push(reporter);
}
// for babe equivocation reports the number of reporters
// and offenders is always 1
let reporters = vec![account("reporter", 1, SEED)];

// make sure reporters actually get rewarded
Staking::<T>::set_slash_reward_fraction(Perbill::one());

let (mut offenders, raw_offenders) = make_offenders::<T>(o, n)?;
let (mut offenders, raw_offenders) = make_offenders::<T>(1, n)?;
let keys = ImOnline::<T>::keys();

let offence = BabeEquivocationOffence {
Expand All @@ -357,9 +352,9 @@ benchmarks! {
assert_eq!(
System::<T>::event_count(), 0
+ 1 // offence
+ 2 * r // reporter (reward + endowment)
+ o // offenders slashed
+ o * n // nominators slashed
+ 2 // reporter (reward + endowment)
+ 1 // offenders slashed
+ n // nominators slashed
);
}

Expand Down

0 comments on commit 15b1000

Please sign in to comment.