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
@@ -259,19 +259,6 @@ impl<T: Config<I>, I: 'static, const MIN_RANK: u16> EnsureOrigin<T::RuntimeOrigi
let who = IndexToId::<T, I>::get(MIN_RANK, 0).ok_or(())?;
Ok(frame_system::RawOrigin::Signed(who).into())
}
#[cfg(feature = "runtime-benchmarks")]
fn successful_origin() -> T::RuntimeOrigin {
match Self::try_successful_origin() {
Ok(o) => o,
Err(()) => {
let who: T::AccountId = frame_benchmarking::whitelisted_caller();
crate::Pallet::<T, I>::do_add_member_to_rank(who.clone(), MIN_RANK)
.expect("failed to add ranked member");
frame_system::RawOrigin::Signed(who).into()
},
}
}
}
/// Guard to ensure that the given origin is a member of the collective. The account ID of the
@@ -295,19 +282,6 @@ impl<T: Config<I>, I: 'static, const MIN_RANK: u16> EnsureOrigin<T::RuntimeOrigi
let who = IndexToId::<T, I>::get(MIN_RANK, 0).ok_or(())?;
Ok(frame_system::RawOrigin::Signed(who).into())
}
#[cfg(feature = "runtime-benchmarks")]
fn successful_origin() -> T::RuntimeOrigin {
match Self::try_successful_origin() {
Ok(o) => o,
Err(()) => {
let who: T::AccountId = frame_benchmarking::whitelisted_caller();
crate::Pallet::<T, I>::do_add_member_to_rank(who.clone(), MIN_RANK)
.expect("failed to add ranked member");
frame_system::RawOrigin::Signed(who).into()
},
}
}
}
/// Guard to ensure that the given origin is a member of the collective. The pair of both the
@@ -331,19 +305,6 @@ impl<T: Config<I>, I: 'static, const MIN_RANK: u16> EnsureOrigin<T::RuntimeOrigi
let who = IndexToId::<T, I>::get(MIN_RANK, 0).ok_or(())?;
Ok(frame_system::RawOrigin::Signed(who).into())
}
#[cfg(feature = "runtime-benchmarks")]
fn successful_origin() -> T::RuntimeOrigin {
match Self::try_successful_origin() {
Ok(o) => o,
Err(()) => {
let who: T::AccountId = frame_benchmarking::whitelisted_caller();
crate::Pallet::<T, I>::do_add_member_to_rank(who.clone(), MIN_RANK)
.expect("failed to add ranked member");
frame_system::RawOrigin::Signed(who).into()
},
}
}
}
#[frame_support::pallet]