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

Commit

Permalink
Fix some broken benchmarks (#6528)
Browse files Browse the repository at this point in the history
  • Loading branch information
shawntabrizi authored Jun 28, 2020
1 parent 11d2899 commit 0a91a5f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions frame/democracy/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ fn add_referendum<T: Trait>(n: u32) -> Result<ReferendumIndex, &'static str> {
0.into(),
);
let referendum_index: ReferendumIndex = ReferendumCount::get() - 1;
let _ = T::Scheduler::schedule_named(
T::Scheduler::schedule_named(
(DEMOCRACY_ID, referendum_index).encode(),
0.into(),
1.into(),
None,
63,
Call::enact_proposal(proposal_hash, referendum_index).into(),
);
).map_err(|_| "failed to schedule named")?;
Ok(referendum_index)
}

Expand Down
5 changes: 2 additions & 3 deletions frame/multisig/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use super::*;
use frame_system::RawOrigin;
use frame_benchmarking::{benchmarks, account};
use sp_runtime::traits::{Bounded, Saturating};
use sp_runtime::traits::Bounded;
use core::convert::TryInto;

use crate::Module as Multisig;
Expand All @@ -36,8 +36,7 @@ fn setup_multi<T: Trait>(s: u32, z: u32)
for i in 0 .. s {
let signatory = account("signatory", i, SEED);
// Give them some balance for a possible deposit
let deposit = T::DepositBase::get() + T::DepositFactor::get() * s.into();
let balance = T::Currency::minimum_balance().saturating_mul(100.into()) + deposit;
let balance = BalanceOf::<T>::max_value();
T::Currency::make_free_balance_be(&signatory, balance);
signatories.push(signatory);
}
Expand Down
13 changes: 7 additions & 6 deletions frame/scheduler/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use crate::Module as Scheduler;
use frame_system::Module as System;

const MAX_SCHEDULED: u32 = 50;
const BLOCK_NUMBER: u32 = 2;

// Add `n` named items to the schedule
fn fill_schedule<T: Trait> (when: T::BlockNumber, n: u32) -> Result<(), &'static str> {
Expand All @@ -55,7 +56,7 @@ benchmarks! {

schedule {
let s in 0 .. MAX_SCHEDULED;
let when = T::BlockNumber::one();
let when = BLOCK_NUMBER.into();
let periodic = Some((T::BlockNumber::one(), 100));
let priority = 0;
// Essentially a no-op call.
Expand All @@ -72,7 +73,7 @@ benchmarks! {

cancel {
let s in 1 .. MAX_SCHEDULED;
let when: T::BlockNumber = 2.into();
let when = BLOCK_NUMBER.into();

fill_schedule::<T>(when, s)?;
assert_eq!(Agenda::<T>::get(when).len(), s as usize);
Expand All @@ -92,7 +93,7 @@ benchmarks! {
schedule_named {
let s in 0 .. MAX_SCHEDULED;
let id = s.encode();
let when = T::BlockNumber::one();
let when = BLOCK_NUMBER.into();
let periodic = Some((T::BlockNumber::one(), 100));
let priority = 0;
// Essentially a no-op call.
Expand All @@ -109,7 +110,7 @@ benchmarks! {

cancel_named {
let s in 1 .. MAX_SCHEDULED;
let when = T::BlockNumber::one();
let when = BLOCK_NUMBER.into();

fill_schedule::<T>(when, s)?;
}: _(RawOrigin::Root, 0.encode())
Expand All @@ -127,9 +128,9 @@ benchmarks! {

on_initialize {
let s in 0 .. MAX_SCHEDULED;
let when = T::BlockNumber::one();
let when = BLOCK_NUMBER.into();
fill_schedule::<T>(when, s)?;
}: { Scheduler::<T>::on_initialize(T::BlockNumber::one()); }
}: { Scheduler::<T>::on_initialize(BLOCK_NUMBER.into()); }
verify {
assert_eq!(System::<T>::event_count(), s);
// Next block should have all the schedules again
Expand Down

0 comments on commit 0a91a5f

Please sign in to comment.