mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 17:31:03 +00:00
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:
committed by
GitHub
parent
1ebcbe1c34
commit
6ec82c7a83
@@ -24,7 +24,10 @@ use super::*;
|
||||
use frame_benchmarking::{
|
||||
account, benchmarks, impl_benchmark_test_suite, whitelist, BenchmarkError, BenchmarkResult,
|
||||
};
|
||||
use frame_support::{dispatch::DispatchResultWithPostInfo, traits::OnInitialize};
|
||||
use frame_support::{
|
||||
dispatch::{DispatchResultWithPostInfo, UnfilteredDispatchable},
|
||||
traits::OnInitialize,
|
||||
};
|
||||
use frame_system::RawOrigin;
|
||||
|
||||
use crate::Pallet as Elections;
|
||||
@@ -401,15 +404,23 @@ benchmarks! {
|
||||
|
||||
let _ = fill_seats_up_to::<T>(m)?;
|
||||
let removing = as_lookup::<T>(<Elections<T>>::members_ids()[0].clone());
|
||||
let who = T::Lookup::lookup(removing.clone()).expect("member was added above");
|
||||
let call = Call::<T>::remove_member { who: removing, has_replacement: false }.encode();
|
||||
}: {
|
||||
assert_eq!(
|
||||
<Elections<T>>::remove_member(RawOrigin::Root.into(), removing, false).unwrap_err().error,
|
||||
<Call<T> as Decode>::decode(&mut &*call)
|
||||
.expect("call is encoded above, encoding must be correct")
|
||||
.dispatch_bypass_filter(RawOrigin::Root.into())
|
||||
.unwrap_err()
|
||||
.error,
|
||||
Error::<T>::InvalidReplacement.into(),
|
||||
);
|
||||
}
|
||||
verify {
|
||||
// must still have enough members.
|
||||
assert_eq!(<Elections<T>>::members().len() as u32, T::DesiredMembers::get());
|
||||
// on fail, `who` must still be a member
|
||||
assert!(<Elections<T>>::members_ids().contains(&who));
|
||||
#[cfg(test)]
|
||||
{
|
||||
// reset members in between benchmark tests.
|
||||
|
||||
Reference in New Issue
Block a user