mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 12:27:56 +00:00
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:
@@ -40,25 +40,12 @@ pub trait EnsureOrigin<OuterOrigin> {
|
||||
/// Perform the origin check.
|
||||
fn try_origin(o: OuterOrigin) -> Result<Self::Success, OuterOrigin>;
|
||||
|
||||
/// Returns an outer origin capable of passing `try_origin` check.
|
||||
///
|
||||
/// NOTE: This should generally *NOT* be reimplemented. Instead implement
|
||||
/// `try_successful_origin`.
|
||||
/// Attempt to get an outer origin capable of passing `try_origin` check. May return `Err` if it
|
||||
/// is impossible.
|
||||
///
|
||||
/// ** Should be used for benchmarking only!!! **
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn successful_origin() -> OuterOrigin {
|
||||
Self::try_successful_origin().expect("No origin exists which can satisfy the guard")
|
||||
}
|
||||
|
||||
/// Attept to get an outer origin capable of passing `try_origin` check. May return `Err` if it
|
||||
/// is impossible. Default implementation just uses `successful_origin()`.
|
||||
///
|
||||
/// ** Should be used for benchmarking only!!! **
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn try_successful_origin() -> Result<OuterOrigin, ()> {
|
||||
Ok(Self::successful_origin())
|
||||
}
|
||||
fn try_successful_origin() -> Result<OuterOrigin, ()>;
|
||||
}
|
||||
|
||||
/// [`EnsureOrigin`] implementation that always fails.
|
||||
@@ -171,25 +158,12 @@ pub trait EnsureOriginWithArg<OuterOrigin, Argument> {
|
||||
/// Perform the origin check, returning the origin value if unsuccessful. This allows chaining.
|
||||
fn try_origin(o: OuterOrigin, a: &Argument) -> Result<Self::Success, OuterOrigin>;
|
||||
|
||||
/// Returns an outer origin capable of passing `try_origin` check.
|
||||
///
|
||||
/// NOTE: This should generally *NOT* be reimplemented. Instead implement
|
||||
/// `try_successful_origin`.
|
||||
/// Attempt to get an outer origin capable of passing `try_origin` check. May return `Err` if it
|
||||
/// is impossible.
|
||||
///
|
||||
/// ** Should be used for benchmarking only!!! **
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn successful_origin(a: &Argument) -> OuterOrigin {
|
||||
Self::try_successful_origin(a).expect("No origin exists which can satisfy the guard")
|
||||
}
|
||||
|
||||
/// Attept to get an outer origin capable of passing `try_origin` check. May return `Err` if it
|
||||
/// is impossible. Default implementation just uses `successful_origin()`.
|
||||
///
|
||||
/// ** Should be used for benchmarking only!!! **
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn try_successful_origin(a: &Argument) -> Result<OuterOrigin, ()> {
|
||||
Ok(Self::successful_origin(a))
|
||||
}
|
||||
fn try_successful_origin(a: &Argument) -> Result<OuterOrigin, ()>;
|
||||
}
|
||||
|
||||
pub struct AsEnsureOriginWithArg<EO>(sp_std::marker::PhantomData<EO>);
|
||||
|
||||
Reference in New Issue
Block a user