Fix Origins Used in Runtime Benchmarks (#12037)

* fix identity benchmark origin

* fix benchmarking macro

* bounties

* democracy

* scheduler

* tips and treasury

* unused

* dunno, this is causing issues
This commit is contained in:
Shawn Tabrizi
2022-08-16 11:36:34 +01:00
committed by GitHub
parent a467983398
commit 2fd028156e
8 changed files with 65 additions and 41 deletions
+18 -15
View File
@@ -37,7 +37,8 @@ fn create_approved_bounties<T: Config<I>, I: 'static>(n: u32) -> Result<(), &'st
setup_bounty::<T, I>(i, T::MaximumReasonLength::get());
Bounties::<T, I>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
let bounty_id = BountyCount::<T, I>::get() - 1;
Bounties::<T, I>::approve_bounty(RawOrigin::Root.into(), bounty_id)?;
let approve_origin = T::ApproveOrigin::successful_origin();
Bounties::<T, I>::approve_bounty(approve_origin, bounty_id)?;
}
ensure!(BountyApprovals::<T, I>::get().len() == n as usize, "Not all bounty approved");
Ok(())
@@ -67,14 +68,10 @@ fn create_bounty<T: Config<I>, I: 'static>(
let curator_lookup = T::Lookup::unlookup(curator.clone());
Bounties::<T, I>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
let bounty_id = BountyCount::<T, I>::get() - 1;
Bounties::<T, I>::approve_bounty(RawOrigin::Root.into(), bounty_id)?;
let approve_origin = T::ApproveOrigin::successful_origin();
Bounties::<T, I>::approve_bounty(approve_origin.clone(), bounty_id)?;
Treasury::<T, I>::on_initialize(T::BlockNumber::zero());
Bounties::<T, I>::propose_curator(
RawOrigin::Root.into(),
bounty_id,
curator_lookup.clone(),
fee,
)?;
Bounties::<T, I>::propose_curator(approve_origin, bounty_id, curator_lookup.clone(), fee)?;
Bounties::<T, I>::accept_curator(RawOrigin::Signed(curator).into(), bounty_id)?;
Ok((curator_lookup, bounty_id))
}
@@ -100,7 +97,8 @@ benchmarks_instance_pallet! {
let (caller, curator, fee, value, reason) = setup_bounty::<T, I>(0, T::MaximumReasonLength::get());
Bounties::<T, I>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
let bounty_id = BountyCount::<T, I>::get() - 1;
}: _(RawOrigin::Root, bounty_id)
let approve_origin = T::ApproveOrigin::successful_origin();
}: _<T::Origin>(approve_origin, bounty_id)
propose_curator {
setup_pot_account::<T, I>();
@@ -108,9 +106,11 @@ benchmarks_instance_pallet! {
let curator_lookup = T::Lookup::unlookup(curator);
Bounties::<T, I>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
let bounty_id = BountyCount::<T, I>::get() - 1;
Bounties::<T, I>::approve_bounty(RawOrigin::Root.into(), bounty_id)?;
let approve_origin = T::ApproveOrigin::successful_origin();
Bounties::<T, I>::approve_bounty(approve_origin, bounty_id)?;
Treasury::<T, I>::on_initialize(T::BlockNumber::zero());
}: _(RawOrigin::Root, bounty_id, curator_lookup, fee)
let approve_origin = T::ApproveOrigin::successful_origin();
}: _<T::Origin>(approve_origin, bounty_id, curator_lookup, fee)
// Worst case when curator is inactive and any sender unassigns the curator.
unassign_curator {
@@ -128,9 +128,10 @@ benchmarks_instance_pallet! {
let curator_lookup = T::Lookup::unlookup(curator.clone());
Bounties::<T, I>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
let bounty_id = BountyCount::<T, I>::get() - 1;
Bounties::<T, I>::approve_bounty(RawOrigin::Root.into(), bounty_id)?;
let approve_origin = T::ApproveOrigin::successful_origin();
Bounties::<T, I>::approve_bounty(approve_origin.clone(), bounty_id)?;
Treasury::<T, I>::on_initialize(T::BlockNumber::zero());
Bounties::<T, I>::propose_curator(RawOrigin::Root.into(), bounty_id, curator_lookup, fee)?;
Bounties::<T, I>::propose_curator(approve_origin, bounty_id, curator_lookup, fee)?;
}: _(RawOrigin::Signed(curator), bounty_id)
award_bounty {
@@ -169,14 +170,16 @@ benchmarks_instance_pallet! {
let (caller, curator, fee, value, reason) = setup_bounty::<T, I>(0, 0);
Bounties::<T, I>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
let bounty_id = BountyCount::<T, I>::get() - 1;
}: close_bounty(RawOrigin::Root, bounty_id)
let approve_origin = T::ApproveOrigin::successful_origin();
}: close_bounty<T::Origin>(approve_origin, bounty_id)
close_bounty_active {
setup_pot_account::<T, I>();
let (curator_lookup, bounty_id) = create_bounty::<T, I>()?;
Treasury::<T, I>::on_initialize(T::BlockNumber::zero());
let bounty_id = BountyCount::<T, I>::get() - 1;
}: close_bounty(RawOrigin::Root, bounty_id)
let approve_origin = T::ApproveOrigin::successful_origin();
}: close_bounty<T::Origin>(approve_origin, bounty_id)
verify {
assert_last_event::<T, I>(Event::BountyCanceled { index: bounty_id }.into())
}