Hey valuable Substrate pros,
do you know a way to use impl_benchmark_test_suite
inside another crate like the runtime? I have multiple pallets. There are no mocks inside these pallets. There is only one runtime mock in my project. Since impl_benchmark_test_suite
needs the mock, I would like to find a way to call the benchmark tests in an outer crate like the runtime.
#[cfg(test)]
#[cfg(feature = "runtime-benchmarks")]
mod benchmark_tests {
use super::*;
use frame_benchmarking::impl_benchmark_test_suite;
impl_benchmark_test_suite!(
my_pallet_1::Pallet,
crate::mock::ExtBuilder::default().build(),
crate::mock::Test,
benchmarks_path = my_pallet_1::benchmarking,
);
impl_benchmark_test_suite!(
my_pallet_2::Pallet,
crate::mock::ExtBuilder::default().build(),
crate::mock::Test,
benchmarks_path = my_pallet_2::benchmarking,
);
impl_benchmark_test_suite!(
my_pallet_3::Pallet,
crate::mock::ExtBuilder::default().build(),
crate::mock::Test,
benchmarks_path = my_pallet_3::benchmarking,
);
}
This produces that error:
error: no rules expected the token `::`
my_pallet_1::Pallet
no rules expected this token in macro call
EDIT:
Trying to use the benchmark test module inside the mock of the runtime:
#[cfg(feature = "runtime-benchmarks")]
mod benchmark_tests {
use frame_benchmarking::impl_benchmark_test_suite;
use my_pallet::Pallet;
impl_benchmark_test_suite!(
Pallet,
ExtBuilder::default().build(),
Test,
benchmarks_path = my_pallet::benchmarking,
);
}
This produces this error:
error: no rules expected the token `)`
375 | / impl_benchmark_test_suite!(
376 | | Pallet,
377 | | ExtBuilder::default().build(),
378 | | Test,
379 | | benchmarks_path = my_pallet::benchmarking,
380 | | );
| |_____^ no rules expected this token in macro call
EDIT 2:
I tried another approach: Just using the mock runtime and ExtBuilder from another pallet.
Inside my_pallet/benchmarking.rs:
impl_benchmark_test_suite!(Pallet, pallet_tests::ExtBuilder::default().build(), pallet_tests::Test);
Although ExtBuilder and Test is public in pallet_tests
it produces the following error:
failed to resolve: could not find `ExtBuilder` in `pallet_tests`
could not find `ExtBuilder` in `pallet_tests`
cannot find type `Test` in crate `pallet_tests`