Skip to content
Snippets Groups Projects
Unverified Commit 7ac70f92 authored by bgallois's avatar bgallois
Browse files

refac(benchmark) refactore BenchmarkSetupHandler

parent 741b15a6
No related branches found
No related tags found
1 merge request!185Fix benchmarks
Pipeline #33673 waiting for manual action
...@@ -125,10 +125,11 @@ where ...@@ -125,10 +125,11 @@ where
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
pub struct BenchmarkSetupHandler<T>(PhantomData<T>); pub struct BenchmarkSetupHandler<T>(PhantomData<T>);
// Macro implementing the BenchmarkSetupHandler trait for pallets requiring identity preparation for benchmarks.
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
impl<T> macro_rules! impl_benchmark_setup_handler {
pallet_identity::traits::SetDistance<<T as pallet_identity::Config>::IdtyIndex, T::AccountId> ($t:ty) => {
for BenchmarkSetupHandler<T> impl<T> $t for BenchmarkSetupHandler<T>
where where
T: pallet_distance::Config, T: pallet_distance::Config,
{ {
...@@ -141,21 +142,13 @@ where ...@@ -141,21 +142,13 @@ where
Some((account.clone(), pallet_distance::DistanceStatus::Valid)), Some((account.clone(), pallet_distance::DistanceStatus::Valid)),
); );
} }
// TODO: All the required preparation for the benchmarks, depending on the coupling
// between pallets, would be implemented here when moving away from prepared identities from the gdev-benchmark.
}
};
} }
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
impl<T> pallet_membership::SetDistance<<T as pallet_identity::Config>::IdtyIndex, T::AccountId> impl_benchmark_setup_handler!(pallet_membership::SetDistance<<T as pallet_identity::Config>::IdtyIndex, T::AccountId>);
for BenchmarkSetupHandler<T> #[cfg(feature = "runtime-benchmarks")]
where impl_benchmark_setup_handler!(pallet_identity::traits::SetDistance<<T as pallet_identity::Config>::IdtyIndex, T::AccountId>);
T: pallet_distance::Config,
{
fn force_status_ok(
idty_id: &<T as pallet_identity::Config>::IdtyIndex,
account: &<T as frame_system::Config>::AccountId,
) -> () {
let _ = pallet_distance::Pallet::<T>::set_distance_status(
*idty_id,
Some((account.clone(), pallet_distance::DistanceStatus::Valid)),
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment