Test each benchmark case in own #[test] (#9860)

* Generate one #[test] fn per bench case.

* Update benchmark macro syntax in frame pallets.

* Explain new benchmark macro syntax in example pallet.

* support with and without a semicolon

* update pallets to use individual tests

* migrate staking too

* migrate more pallets

* fix up democracy and use individual tests

* Fix comment

* Put println message in panic

* Remove `another_set_dummy` from doc

`another_set_dummy` is not present in the benchmarking.rs (anymore).

* Update doc for benchmarks macro

* Update doc for impl_benchmark_test_suite macro

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
ucover
2021-10-01 10:17:26 +02:00
committed by GitHub
parent a31ab1fc37
commit f8ce186496
39 changed files with 499 additions and 173 deletions
@@ -19,7 +19,7 @@
use super::*;
use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelist_account};
use frame_benchmarking::{account, benchmarks, whitelist_account};
use frame_support::{
assert_noop, assert_ok,
codec::Decode,
@@ -70,7 +70,7 @@ fn add_referendum<T: Config>(n: u32) -> Result<ReferendumIndex, &'static str> {
let referendum_index: ReferendumIndex = ReferendumCount::<T>::get() - 1;
T::Scheduler::schedule_named(
(DEMOCRACY_ID, referendum_index).encode(),
DispatchTime::At(1u32.into()),
DispatchTime::At(2u32.into()),
None,
63,
frame_system::RawOrigin::Root.into(),
@@ -802,6 +802,10 @@ benchmarks! {
Err(Error::<T>::PreimageInvalid.into())
);
}
}
impl_benchmark_test_suite!(Democracy, crate::tests::new_test_ext(), crate::tests::Test);
impl_benchmark_test_suite!(
Democracy,
crate::tests::new_test_ext(),
crate::tests::Test
);
}
+1 -1
View File
@@ -149,7 +149,7 @@
//! - `cancel_queued` - Cancels a proposal that is queued for enactment.
//! - `clear_public_proposal` - Removes all public proposals.
#![recursion_limit = "128"]
#![recursion_limit = "256"]
#![cfg_attr(not(feature = "std"), no_std)]
use codec::{Decode, Encode, Input};