|
17 | 17 | use crate::*;
|
18 | 18 | use frame_support::traits::{fungible::Mutate, fungibles::Inspect};
|
19 | 19 | use itertools::Itertools;
|
20 |
| -use pallet_funding::{assert_close_enough, types::*, ProjectId}; |
| 20 | +use pallet_funding::{assert_close_enough, types::*, ProjectId, WeightInfo}; |
21 | 21 | use polimec_common::migration_types::{MigrationStatus, Migrations, ParticipationType};
|
22 | 22 | use polimec_runtime::{Funding, RuntimeOrigin};
|
23 | 23 | use polkadot_service::chain_spec::get_account_id_from_seed;
|
24 | 24 | use sp_runtime::Perquintill;
|
25 | 25 | use std::collections::HashMap;
|
26 | 26 | use tests::defaults::*;
|
| 27 | +use xcm_executor::traits::WeightBounds; |
27 | 28 |
|
28 | 29 | fn alice() -> AccountId {
|
29 | 30 | get_account_id_from_seed::<sr25519::Public>(ALICE)
|
@@ -318,3 +319,25 @@ fn cannot_start_pallet_migration_with_unsettled_participations() {
|
318 | 319 | });
|
319 | 320 | }
|
320 | 321 | }
|
| 322 | + |
| 323 | +#[test] |
| 324 | +fn hrmp_functions_weight_is_under_assumed_maximum() { |
| 325 | + type WeightInfo = <PolimecRuntime as pallet_funding::Config>::WeightInfo; |
| 326 | + type XcmWeigher = <polimec_runtime::xcm_config::XcmConfig as polimec_xcm_executor::Config>::Weigher; |
| 327 | + |
| 328 | + let open_channel_message = xcm::v3::Instruction::<PolimecCall>::HrmpNewChannelOpenRequest { |
| 329 | + sender: 6969, |
| 330 | + max_message_size: 102_300, |
| 331 | + max_capacity: 1000, |
| 332 | + }; |
| 333 | + let channel_accepted_message = xcm::v3::Instruction::<PolimecCall>::HrmpChannelAccepted { recipient: 6969u32 }; |
| 334 | + |
| 335 | + let open_channel_message_real_weight = WeightInfo::do_handle_channel_open_request(); |
| 336 | + let open_channel_message_deducted_weight = XcmWeigher::instr_weight(&open_channel_message).unwrap(); |
| 337 | + |
| 338 | + let channel_accepted_message_real_weight = WeightInfo::do_handle_channel_accepted(); |
| 339 | + let channel_accepted_message_deducted_weight = XcmWeigher::instr_weight(&channel_accepted_message).unwrap(); |
| 340 | + |
| 341 | + assert!(open_channel_message_deducted_weight.all_gte(open_channel_message_real_weight)); |
| 342 | + assert!(channel_accepted_message_deducted_weight.all_gte(channel_accepted_message_real_weight)); |
| 343 | +} |
0 commit comments