assets_common/
benchmarks.rs1use core::{fmt::Debug, marker::PhantomData};
17use cumulus_primitives_core::ParaId;
18use sp_runtime::traits::Get;
19use xcm::latest::prelude::*;
20
21pub struct AssetPairFactory<Target, SelfParaId, PalletId, L = Location>(
23 PhantomData<(Target, SelfParaId, PalletId, L)>,
24);
25impl<Target: Get<L>, SelfParaId: Get<ParaId>, PalletId: Get<u32>, L: TryFrom<Location> + Debug>
26 pallet_asset_conversion::BenchmarkHelper<L> for AssetPairFactory<Target, SelfParaId, PalletId, L>
27where
28 <L as TryFrom<Location>>::Error: Debug,
29{
30 fn create_pair(seed1: u32, seed2: u32) -> (L, L) {
31 let with_id = Location::new(
32 1,
33 [
34 Parachain(SelfParaId::get().into()),
35 PalletInstance(PalletId::get() as u8),
36 GeneralIndex(seed2.into()),
37 ],
38 );
39 if seed1 % 2 == 0 {
40 (
41 with_id
42 .try_into()
43 .map_err(|error| {
44 tracing::error!(
45 target: "xcm",
46 ?error,
47 "Failed to create asset pairs when seed1 is even",
48 );
49 "Something went wrong"
50 })
51 .unwrap(),
52 Target::get(),
53 )
54 } else {
55 (
56 Target::get(),
57 with_id
58 .try_into()
59 .map_err(|error| {
60 tracing::error!(target: "xcm", ?error, "Failed to create asset pairs");
61 "Something went wrong"
62 })
63 .unwrap(),
64 )
65 }
66 }
67}