Benchmark's successful origin api update (#13146)

* try successful origin unimplemented by default

* error as a default impl for try_successful_origin

* remove successful_origin func of EnsureOrigin trait

* default impl -> unimplemented!()

* update EnsureOriginWithArg

* fix EnsureOriginWithArg

* prefix unused arg with underscore

* use try_successful_origin instead successful_origin, map err to Weightless

* fix tests

* remove default impl

* unwrap for indirect origin dep

* replace unwrap by expect with a message

---------

Co-authored-by: parity-processbot <>
This commit is contained in:
Muharem Ismailov
2023-02-01 03:11:41 +01:00
committed by GitHub
parent a46203efb6
commit 3079a17c94
21 changed files with 402 additions and 243 deletions
+7 -4
View File
@@ -21,7 +21,7 @@
use super::{Pallet as Treasury, *};
use frame_benchmarking::v1::{account, benchmarks_instance_pallet};
use frame_benchmarking::v1::{account, benchmarks_instance_pallet, BenchmarkError};
use frame_support::{
dispatch::UnfilteredDispatchable,
ensure,
@@ -99,7 +99,8 @@ benchmarks_instance_pallet! {
beneficiary_lookup
)?;
let proposal_id = Treasury::<T, _>::proposal_count() - 1;
let reject_origin = T::RejectOrigin::successful_origin();
let reject_origin =
T::RejectOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
}: _<T::RuntimeOrigin>(reject_origin, proposal_id)
approve_proposal {
@@ -112,7 +113,8 @@ benchmarks_instance_pallet! {
beneficiary_lookup
)?;
let proposal_id = Treasury::<T, _>::proposal_count() - 1;
let approve_origin = T::ApproveOrigin::successful_origin();
let approve_origin =
T::ApproveOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
}: _<T::RuntimeOrigin>(approve_origin, proposal_id)
remove_approval {
@@ -124,7 +126,8 @@ benchmarks_instance_pallet! {
)?;
let proposal_id = Treasury::<T, _>::proposal_count() - 1;
Treasury::<T, I>::approve_proposal(RawOrigin::Root.into(), proposal_id)?;
let reject_origin = T::RejectOrigin::successful_origin();
let reject_origin =
T::RejectOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
}: _<T::RuntimeOrigin>(reject_origin, proposal_id)
on_initialize_proposals {