Add weight for decoding the call to benchmarks (#9781)

* First two bechmarks converted

* Add decoding weight to benchmarks.

* Update frame/democracy/src/benchmarking.rs

* Adapt to new Call-ing convention

* Resolve conflicts and change more calls

* Remove error impl for codec and use plain `expect` for error handling instead

* Compile fix

* Spaces to tabs

* Update frame/democracy/src/benchmarking.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Add origin-type specifier to benchmarks macro

* formatting

* Update frame/benchmarking/src/lib.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Change manual to automatic benchmark syntax

* Formatting

* Revert "Change manual to automatic benchmark syntax"

This reverts commit ea5b5d906b318b6525c1e6d2bd05c5011595c21a.

Because tests are lost and cleanup code in the verify function is not run on failing calls.

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
Falco Hirschenberger
2021-09-27 17:17:38 +02:00
committed by GitHub
parent 1ebcbe1c34
commit 6ec82c7a83
9 changed files with 75 additions and 60 deletions
+4 -9
View File
@@ -22,7 +22,7 @@
use super::*;
use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller};
use frame_support::traits::{EnsureOrigin, OnInitialize, UnfilteredDispatchable};
use frame_support::traits::{EnsureOrigin, OnInitialize};
use frame_system::RawOrigin;
use sp_runtime::traits::{Bounded, Zero};
@@ -73,11 +73,9 @@ benchmarks! {
set_calls {
let n in 0 .. T::MaxCalls::get() as u32;
let calls = vec![frame_system::Call::<T>::remark { remark: vec![] }.into(); n as usize];
let call = Call::<T>::set_calls { calls };
let origin = T::ManagerOrigin::successful_origin();
assert!(CallIndices::<T>::get().is_empty());
}: { call.dispatch_bypass_filter(origin)? }
}: _<T::Origin>(origin, calls)
verify {
if !n.is_zero() {
assert!(!CallIndices::<T>::get().is_empty());
@@ -88,10 +86,8 @@ benchmarks! {
let price = BalanceOf::<T>::max_value();
let end = 10u32.into();
let payout = 5u32.into();
let call = Call::<T>::start_lottery { price, length: end, delay: payout, repeat: true };
let origin = T::ManagerOrigin::successful_origin();
}: { call.dispatch_bypass_filter(origin)? }
}: _<T::Origin>(origin, price, end, payout, true)
verify {
assert!(crate::Lottery::<T>::get().is_some());
}
@@ -99,9 +95,8 @@ benchmarks! {
stop_repeat {
setup_lottery::<T>(true)?;
assert_eq!(crate::Lottery::<T>::get().unwrap().repeat, true);
let call = Call::<T>::stop_repeat {};
let origin = T::ManagerOrigin::successful_origin();
}: { call.dispatch_bypass_filter(origin)? }
}: _<T::Origin>(origin)
verify {
assert_eq!(crate::Lottery::<T>::get().unwrap().repeat, false);
}