Skip to content

Commit

Permalink
Short circuit Treasury::Spend benchmark for NeverEnsureOrigin (parity…
Browse files Browse the repository at this point in the history
…tech#11562)

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

Co-authored-by: parity-processbot <>
  • Loading branch information
ggwpez authored and ark0f committed Feb 27, 2023
1 parent 73bb014 commit 8a814fb
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 8a814fb

Please sign in to comment.