Introduce EnsureOrigin::try_successul_origin (#11558)

* Introduce `EnsureOrigin::try_successul_origin`

* Formatting

* Fixes

* Add Morph

* Fixes

* Formatting
This commit is contained in:
Gavin Wood
2022-05-31 19:12:07 +01:00
committed by GitHub
parent adf0773f9d
commit 9107ae41fd
6 changed files with 221 additions and 97 deletions
+8 -8
View File
@@ -996,11 +996,11 @@ impl<
}
#[cfg(feature = "runtime-benchmarks")]
fn successful_origin() -> O {
fn try_successful_origin() -> Result<O, ()> {
let zero_account_id =
AccountId::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes())
.expect("infinite length input; no invalid inputs for type; qed");
O::from(RawOrigin::Member(zero_account_id))
Ok(O::from(RawOrigin::Member(zero_account_id)))
}
}
@@ -1021,8 +1021,8 @@ impl<
}
#[cfg(feature = "runtime-benchmarks")]
fn successful_origin() -> O {
O::from(RawOrigin::Members(N, N))
fn try_successful_origin() -> Result<O, ()> {
Ok(O::from(RawOrigin::Members(N, N)))
}
}
@@ -1046,8 +1046,8 @@ impl<
}
#[cfg(feature = "runtime-benchmarks")]
fn successful_origin() -> O {
O::from(RawOrigin::Members(1u32, 0u32))
fn try_successful_origin() -> Result<O, ()> {
Ok(O::from(RawOrigin::Members(1u32, 0u32)))
}
}
@@ -1071,7 +1071,7 @@ impl<
}
#[cfg(feature = "runtime-benchmarks")]
fn successful_origin() -> O {
O::from(RawOrigin::Members(0u32, 0u32))
fn try_successful_origin() -> Result<O, ()> {
Ok(O::from(RawOrigin::Members(0u32, 0u32)))
}
}