snowbridge_pallet_system_v2/
benchmarking.rs1use super::*;
5
6#[allow(unused)]
7use crate::Pallet as SnowbridgeControl;
8use frame_benchmarking::v2::*;
9use frame_system::RawOrigin;
10use xcm::prelude::*;
11
12#[benchmarks]
13mod benchmarks {
14 use super::*;
15
16 #[benchmark]
17 fn register_token() -> Result<(), BenchmarkError> {
18 let origin_location = Location::new(1, [Parachain(1000), PalletInstance(36)]);
19 let origin = <T as Config>::Helper::make_xcm_origin(origin_location.clone());
20 let creator = Box::new(VersionedLocation::from(origin_location.clone()));
21 let relay_token_asset_id: Location = Location::parent();
22 let asset = Box::new(VersionedLocation::from(relay_token_asset_id));
23 let asset_metadata = AssetMetadata {
24 name: "wnd".as_bytes().to_vec().try_into().unwrap(),
25 symbol: "wnd".as_bytes().to_vec().try_into().unwrap(),
26 decimals: 12,
27 };
28
29 #[extrinsic_call]
30 _(origin as T::RuntimeOrigin, creator, asset, asset_metadata, 1);
31
32 Ok(())
33 }
34
35 #[benchmark]
36 fn upgrade() -> Result<(), BenchmarkError> {
37 let impl_address = H160::repeat_byte(1);
38 let impl_code_hash = H256::repeat_byte(1);
39
40 let params: Vec<u8> = (0..256).map(|_| 1u8).collect();
42
43 #[extrinsic_call]
44 _(
45 RawOrigin::Root,
46 impl_address,
47 impl_code_hash,
48 Initializer { params, maximum_required_gas: 100000 },
49 );
50
51 Ok(())
52 }
53
54 #[benchmark]
55 fn set_operating_mode() -> Result<(), BenchmarkError> {
56 #[extrinsic_call]
57 _(RawOrigin::Root, OperatingMode::RejectingOutboundMessages);
58
59 Ok(())
60 }
61
62 #[benchmark]
63 fn add_tip() -> Result<(), BenchmarkError> {
64 let origin_location = Location::new(1, [Parachain(1000), PalletInstance(36)]);
65 let origin = <T as Config>::Helper::make_xcm_origin(origin_location.clone());
66 let sender: T::AccountId = whitelisted_caller();
67 let message_id = MessageId::Inbound(1);
68
69 #[extrinsic_call]
70 _(origin as T::RuntimeOrigin, sender, message_id, 1_000_000_000u128);
71
72 Ok(())
73 }
74
75 impl_benchmark_test_suite!(
76 SnowbridgeControl,
77 crate::mock::new_test_ext(true),
78 crate::mock::Test
79 );
80}