mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 16:57:58 +00:00
Propagate DispatchError for benchmarks. (#5075)
* Propagate DispatchError for benchmarks. * Apply review suggestions. * Use RuntimeString. * fix expect Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -31,7 +31,8 @@ pub use node_primitives::{AccountId, Signature};
|
||||
use node_primitives::{AccountIndex, Balance, BlockNumber, Hash, Index, Moment};
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_runtime::{
|
||||
Permill, Perbill, Percent, ApplyExtrinsicResult, impl_opaque_keys, generic, create_runtime_str,
|
||||
Permill, Perbill, Percent, ApplyExtrinsicResult, RuntimeString,
|
||||
impl_opaque_keys, generic, create_runtime_str,
|
||||
};
|
||||
use sp_runtime::curve::PiecewiseLinear;
|
||||
use sp_runtime::transaction_validity::TransactionValidity;
|
||||
@@ -821,15 +822,17 @@ impl_runtime_apis! {
|
||||
extrinsic: Vec<u8>,
|
||||
steps: Vec<u32>,
|
||||
repeat: u32,
|
||||
) -> Option<Vec<frame_benchmarking::BenchmarkResults>> {
|
||||
) -> Result<Vec<frame_benchmarking::BenchmarkResults>, RuntimeString> {
|
||||
use frame_benchmarking::Benchmarking;
|
||||
|
||||
match module.as_slice() {
|
||||
b"pallet-balances" | b"balances" => Balances::run_benchmark(extrinsic, steps, repeat).ok(),
|
||||
b"pallet-identity" | b"identity" => Identity::run_benchmark(extrinsic, steps, repeat).ok(),
|
||||
b"pallet-timestamp" | b"timestamp" => Timestamp::run_benchmark(extrinsic, steps, repeat).ok(),
|
||||
_ => None,
|
||||
}
|
||||
let result = match module.as_slice() {
|
||||
b"pallet-balances" | b"balances" => Balances::run_benchmark(extrinsic, steps, repeat),
|
||||
b"pallet-identity" | b"identity" => Identity::run_benchmark(extrinsic, steps, repeat),
|
||||
b"pallet-timestamp" | b"timestamp" => Timestamp::run_benchmark(extrinsic, steps, repeat),
|
||||
_ => Err("Benchmark not found for this pallet."),
|
||||
};
|
||||
|
||||
result.map_err(|e| e.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user