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

Commit

Permalink
Short circuit Treasury::Spend benchmark for NeverEnsureOrigin (#11562)
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Tale-Yazdi <[email protected]>

Co-authored-by: parity-processbot <>
  • Loading branch information
ggwpez authored May 31, 2022
1 parent 3bfb4cc commit 346471d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions frame/treasury/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,22 @@ fn assert_last_event<T: Config<I>, I: 'static>(generic_event: <T as Config<I>>::
}

benchmarks_instance_pallet! {
// This benchmark is short-circuited if `SpendOrigin` cannot provide
// a successful origin, in which case `spend` is un-callable and can use weight=0.
spend {
let (_, value, beneficiary_lookup) = setup_proposal::<T, _>(SEED);
let origin = T::SpendOrigin::successful_origin();
let origin = T::SpendOrigin::try_successful_origin();
let beneficiary = T::Lookup::lookup(beneficiary_lookup.clone()).unwrap();
let call = Call::<T, I>::spend { amount: value, beneficiary: beneficiary_lookup };
}: { call.dispatch_bypass_filter(origin)? }
}: {
if let Ok(origin) = origin.clone() {
call.dispatch_bypass_filter(origin)?;
}
}
verify {
assert_last_event::<T, I>(Event::SpendApproved { proposal_index: 0, amount: value, beneficiary }.into())
if origin.is_ok() {
assert_last_event::<T, I>(Event::SpendApproved { proposal_index: 0, amount: value, beneficiary }.into())
}
}

propose_spend {
Expand Down

0 comments on commit 346471d

Please sign in to comment.