mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 21:01:05 +00:00
Dont Convert Benchmark Error Too Early (#9743)
* dont convert benchmark error * fix warning * fix more warnings * more fixes * more fixes * add missing feature deps * Update frame/election-provider-multi-phase/src/benchmarking.rs Co-authored-by: Alexander Theißen <alex.theissen@me.com> * Update frame/election-provider-multi-phase/src/benchmarking.rs Co-authored-by: Alexander Theißen <alex.theissen@me.com> * use from Co-authored-by: Alexander Theißen <alex.theissen@me.com>
This commit is contained in:
@@ -644,7 +644,7 @@ macro_rules! benchmark_backend {
|
||||
&self,
|
||||
components: &[($crate::BenchmarkParameter, u32)],
|
||||
verify: bool
|
||||
) -> Result<$crate::Box<dyn FnOnce() -> Result<(), $crate::BenchmarkError>>, &'static str> {
|
||||
) -> Result<$crate::Box<dyn FnOnce() -> Result<(), $crate::BenchmarkError>>, $crate::BenchmarkError> {
|
||||
$(
|
||||
// Prepare instance
|
||||
let $param = components.iter()
|
||||
@@ -717,7 +717,7 @@ macro_rules! selected_benchmark {
|
||||
&self,
|
||||
components: &[($crate::BenchmarkParameter, u32)],
|
||||
verify: bool
|
||||
) -> Result<$crate::Box<dyn FnOnce() -> Result<(), $crate::BenchmarkError>>, &'static str> {
|
||||
) -> Result<$crate::Box<dyn FnOnce() -> Result<(), $crate::BenchmarkError>>, $crate::BenchmarkError> {
|
||||
match self {
|
||||
$(
|
||||
Self::$bench => <
|
||||
@@ -1246,7 +1246,7 @@ macro_rules! impl_benchmark_test_suite {
|
||||
}
|
||||
}
|
||||
},
|
||||
Ok(Ok(_)) => (),
|
||||
Ok(Ok(())) => (),
|
||||
}
|
||||
}
|
||||
assert!(!anything_failed);
|
||||
|
||||
@@ -41,6 +41,7 @@ mod pallet_test {
|
||||
pub trait Config: frame_system::Config {
|
||||
type LowerBound: Get<u32>;
|
||||
type UpperBound: Get<u32>;
|
||||
type MaybeItem: Get<Option<u32>>;
|
||||
}
|
||||
|
||||
#[pallet::storage]
|
||||
@@ -112,11 +113,13 @@ impl frame_system::Config for Test {
|
||||
parameter_types! {
|
||||
pub const LowerBound: u32 = 1;
|
||||
pub const UpperBound: u32 = 100;
|
||||
pub const MaybeItem: Option<u32> = None;
|
||||
}
|
||||
|
||||
impl pallet_test::Config for Test {
|
||||
type LowerBound = LowerBound;
|
||||
type UpperBound = UpperBound;
|
||||
type MaybeItem = MaybeItem;
|
||||
}
|
||||
|
||||
fn new_test_ext() -> sp_io::TestExternalities {
|
||||
@@ -218,6 +221,13 @@ mod benchmarks {
|
||||
}
|
||||
))?;
|
||||
}
|
||||
|
||||
skip_benchmark {
|
||||
let value = T::MaybeItem::get().ok_or(BenchmarkError::Skip)?;
|
||||
}: {
|
||||
// This should never be reached.
|
||||
assert!(value > 100);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -334,6 +344,11 @@ mod benchmarks {
|
||||
assert_err!(Pallet::<Test>::test_benchmark_bad_verify(), "You forgot to sort!");
|
||||
assert_ok!(Pallet::<Test>::test_benchmark_no_components());
|
||||
assert_ok!(Pallet::<Test>::test_benchmark_variable_components());
|
||||
assert!(matches!(
|
||||
Pallet::<Test>::test_benchmark_override_benchmark(),
|
||||
Err(BenchmarkError::Override(_)),
|
||||
));
|
||||
assert_eq!(Pallet::<Test>::test_benchmark_skip_benchmark(), Err(BenchmarkError::Skip),);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ pub trait BenchmarkingSetup<T, I = ()> {
|
||||
&self,
|
||||
components: &[(BenchmarkParameter, u32)],
|
||||
verify: bool,
|
||||
) -> Result<Box<dyn FnOnce() -> Result<(), BenchmarkError>>, &'static str>;
|
||||
) -> Result<Box<dyn FnOnce() -> Result<(), BenchmarkError>>, BenchmarkError>;
|
||||
}
|
||||
|
||||
/// Grab an account, seeded by a name and index.
|
||||
|
||||
Reference in New Issue
Block a user