|
| 1 | +// Copyright (C) Moondance Labs Ltd. |
| 2 | +// This file is part of Tanssi. |
| 3 | + |
| 4 | +// Tanssi is free software: you can redistribute it and/or modify |
| 5 | +// it under the terms of the GNU General Public License as published by |
| 6 | +// the Free Software Foundation, either version 3 of the License, or |
| 7 | +// (at your option) any later version. |
| 8 | + |
| 9 | +// Tanssi is distributed in the hope that it will be useful, |
| 10 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +// GNU General Public License for more details. |
| 13 | + |
| 14 | +// You should have received a copy of the GNU General Public License |
| 15 | +// along with Tanssi. If not, see <http://www.gnu.org/licenses/> |
| 16 | + |
| 17 | +#![cfg(feature = "runtime-benchmarks")] |
| 18 | + |
| 19 | +//! Benchmarking |
| 20 | +use { |
| 21 | + crate::{Call, Config, DefaultTrustPolicy, MultiLocation, Pallet, TrustPolicy}, |
| 22 | + frame_benchmarking::{impl_benchmark_test_suite, v2::*}, |
| 23 | + frame_system::RawOrigin, |
| 24 | + sp_std::vec, |
| 25 | + staging_xcm::v3::Junctions::Here, |
| 26 | +}; |
| 27 | + |
| 28 | +#[benchmarks] |
| 29 | +mod benchmarks { |
| 30 | + use super::*; |
| 31 | + |
| 32 | + #[benchmark] |
| 33 | + fn set_reserve_policy() -> Result<(), BenchmarkError> { |
| 34 | + #[extrinsic_call] |
| 35 | + _( |
| 36 | + RawOrigin::Root, |
| 37 | + MultiLocation { |
| 38 | + parents: 1, |
| 39 | + interior: Here, |
| 40 | + }, |
| 41 | + TrustPolicy::DefaultTrustPolicy(DefaultTrustPolicy::Never), |
| 42 | + ); |
| 43 | + |
| 44 | + // assert!( |
| 45 | + Ok(()) |
| 46 | + } |
| 47 | + |
| 48 | + #[benchmark] |
| 49 | + fn remove_reserve_policy() -> Result<(), BenchmarkError> { |
| 50 | + let _ = Pallet::<T>::set_reserve_policy( |
| 51 | + RawOrigin::Root.into(), |
| 52 | + MultiLocation { |
| 53 | + parents: 1, |
| 54 | + interior: Here, |
| 55 | + }, |
| 56 | + TrustPolicy::DefaultTrustPolicy(DefaultTrustPolicy::Never), |
| 57 | + ); |
| 58 | + |
| 59 | + #[extrinsic_call] |
| 60 | + _( |
| 61 | + RawOrigin::Root, |
| 62 | + MultiLocation { |
| 63 | + parents: 1, |
| 64 | + interior: Here, |
| 65 | + }, |
| 66 | + ); |
| 67 | + assert!(Pallet::<T>::reserve_policy(MultiLocation { |
| 68 | + parents: 1, |
| 69 | + interior: Here, |
| 70 | + }) |
| 71 | + .is_none()); |
| 72 | + |
| 73 | + Ok(()) |
| 74 | + } |
| 75 | + |
| 76 | + #[benchmark] |
| 77 | + fn set_teleport_policy() -> Result<(), BenchmarkError> { |
| 78 | + #[extrinsic_call] |
| 79 | + _( |
| 80 | + RawOrigin::Root, |
| 81 | + MultiLocation { |
| 82 | + parents: 1, |
| 83 | + interior: Here, |
| 84 | + }, |
| 85 | + TrustPolicy::DefaultTrustPolicy(DefaultTrustPolicy::Never), |
| 86 | + ); |
| 87 | + |
| 88 | + // assert!( |
| 89 | + Ok(()) |
| 90 | + } |
| 91 | + |
| 92 | + #[benchmark] |
| 93 | + fn remove_teleport_policy() -> Result<(), BenchmarkError> { |
| 94 | + let _ = Pallet::<T>::set_teleport_policy( |
| 95 | + RawOrigin::Root.into(), |
| 96 | + MultiLocation { |
| 97 | + parents: 1, |
| 98 | + interior: Here, |
| 99 | + }, |
| 100 | + TrustPolicy::DefaultTrustPolicy(DefaultTrustPolicy::Never), |
| 101 | + ); |
| 102 | + |
| 103 | + #[extrinsic_call] |
| 104 | + _( |
| 105 | + RawOrigin::Root, |
| 106 | + MultiLocation { |
| 107 | + parents: 1, |
| 108 | + interior: Here, |
| 109 | + }, |
| 110 | + ); |
| 111 | + assert!(Pallet::<T>::teleport_policy(MultiLocation { |
| 112 | + parents: 1, |
| 113 | + interior: Here, |
| 114 | + }) |
| 115 | + .is_none()); |
| 116 | + |
| 117 | + Ok(()) |
| 118 | + } |
| 119 | + |
| 120 | + impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test); |
| 121 | +} |
0 commit comments