referrerpolicy=no-referrer-when-downgrade

snowbridge_pallet_system_frontend/
benchmarking.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com>
3//! Benchmarking setup for pallet-template
4use super::*;
5#[allow(unused)]
6use crate::Pallet as SnowbridgeControlFrontend;
7use frame_benchmarking::v2::*;
8use frame_system::RawOrigin;
9use xcm::prelude::{Location, *};
10use xcm_executor::traits::ConvertLocation;
11
12#[benchmarks(where <T as frame_system::Config>::AccountId: Into<Location>)]
13mod benchmarks {
14	use super::*;
15	#[benchmark]
16	fn register_token() -> Result<(), BenchmarkError> {
17		let origin_location = Location::new(1, [Parachain(2000)]);
18		let origin = T::Helper::make_xcm_origin(origin_location.clone());
19
20		let asset_location: Location = Location::new(1, [Parachain(2000), GeneralIndex(1)]);
21		let asset_id = Box::new(VersionedLocation::from(asset_location.clone()));
22		T::Helper::initialize_storage(asset_location, origin_location.clone());
23
24		let ether = T::EthereumLocation::get();
25		let asset_owner = T::AccountIdConverter::convert_location(&origin_location).unwrap();
26		T::Helper::setup_pools(asset_owner, ether.clone());
27
28		let asset_metadata = AssetMetadata {
29			name: "pal".as_bytes().to_vec().try_into().unwrap(),
30			symbol: "pal".as_bytes().to_vec().try_into().unwrap(),
31			decimals: 12,
32		};
33
34		let fee_asset = Asset::from((Location::parent(), 1_000_000u128));
35
36		#[extrinsic_call]
37		_(origin as T::RuntimeOrigin, asset_id, asset_metadata, fee_asset);
38
39		Ok(())
40	}
41
42	#[benchmark]
43	fn add_tip() -> Result<(), BenchmarkError> {
44		let caller: T::AccountId = whitelisted_caller();
45
46		let ether = T::EthereumLocation::get();
47		T::Helper::setup_pools(caller.clone(), ether.clone());
48
49		let message_id = MessageId::Inbound(1);
50		let dot = Location::new(1, Here);
51		let asset = Asset::from((dot, 1_000_000_00u128));
52
53		#[extrinsic_call]
54		_(RawOrigin::Signed(caller.clone()), message_id, asset);
55
56		Ok(())
57	}
58
59	impl_benchmark_test_suite!(
60		SnowbridgeControlFrontend,
61		crate::mock::new_test_ext(),
62		crate::mock::Test
63	);
64}