Unverified Commit 1311c3dc authored by Shawn Tabrizi's avatar Shawn Tabrizi Committed by GitHub
Browse files

Companion PR for #5436/#5445 + #5463 (#948)

* Use `add_benchmark` macro

* Return error if `batches` is empty

* Update Cargo.lock

* Companion for #5463 (#953)

* Fix test with genesis block 0

* Update Cargo.lock
parent cfbad5fc
Pipeline #85724 passed with stages
in 27 minutes and 30 seconds
This diff is collapsed.
......@@ -787,7 +787,7 @@ mod tests {
#[test]
fn basic_setup_works() {
new_test_ext().execute_with(|| {
assert_eq!(System::block_number(), 1);
assert_eq!(System::block_number(), 0);
assert_eq!(Crowdfund::fund_count(), 0);
assert_eq!(Crowdfund::funds(0), None);
let empty: Vec<FundIndex> = Vec::new();
......
......@@ -899,27 +899,20 @@ sp_api::impl_runtime_apis! {
#[cfg(feature = "runtime-benchmarks")]
impl frame_benchmarking::Benchmark<Block> for Runtime {
fn dispatch_benchmark(
module: Vec<u8>,
extrinsic: Vec<u8>,
pallet: Vec<u8>,
benchmark: Vec<u8>,
lowest_range_values: Vec<u32>,
highest_range_values: Vec<u32>,
steps: Vec<u32>,
repeat: u32,
) -> Result<Vec<frame_benchmarking::BenchmarkResults>, RuntimeString> {
use frame_benchmarking::Benchmarking;
let result = match module.as_slice() {
b"claims" => Claims::run_benchmark(
extrinsic,
lowest_range_values,
highest_range_values,
steps,
repeat,
),
_ => Err("Benchmark not found for this pallet."),
};
result.map_err(|e| e.into())
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark};
let mut batches = Vec::<BenchmarkBatch>::new();
let params = (&pallet, &benchmark, &lowest_range_values, &highest_range_values, &steps, repeat);
add_benchmark!(params, batches, b"claims", Claims);
if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
}
}
}
......@@ -821,27 +821,20 @@ sp_api::impl_runtime_apis! {
#[cfg(feature = "runtime-benchmarks")]
impl frame_benchmarking::Benchmark<Block> for Runtime {
fn dispatch_benchmark(
module: Vec<u8>,
extrinsic: Vec<u8>,
pallet: Vec<u8>,
benchmark: Vec<u8>,
lowest_range_values: Vec<u32>,
highest_range_values: Vec<u32>,
steps: Vec<u32>,
repeat: u32,
) -> Result<Vec<frame_benchmarking::BenchmarkResults>, RuntimeString> {
use frame_benchmarking::Benchmarking;
let result = match module.as_slice() {
b"claims" => Claims::run_benchmark(
extrinsic,
lowest_range_values,
highest_range_values,
steps,
repeat,
),
_ => Err("Benchmark not found for this pallet."),
};
result.map_err(|e| e.into())
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark};
let mut batches = Vec::<BenchmarkBatch>::new();
let params = (&pallet, &benchmark, &lowest_range_values, &highest_range_values, &steps, repeat);
add_benchmark!(params, batches, b"claims", Claims);
if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment