Skip to content

Commit 44b9020

Browse files
bkonturacatangiu
andcommitted
Removed TODO from test-case for hard-coded delivery fee estimation (#2042)
Co-authored-by: Adrian Catangiu <[email protected]>
1 parent 644a1e3 commit 44b9020

3 files changed

Lines changed: 162 additions & 140 deletions

File tree

cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/tests.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -768,29 +768,11 @@ mod asset_hub_rococo_tests {
768768
Runtime,
769769
AllPalletsWithoutSystem,
770770
XcmConfig,
771-
ParachainSystem,
772-
XcmpQueue,
773771
LocationToAccountId,
774772
ToWococoXcmRouterInstance,
775773
>(
776774
collator_session_keys(),
777-
ExistentialDeposit::get(),
778-
AccountId::from(ALICE),
779-
Box::new(|runtime_event_encoded: Vec<u8>| {
780-
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
781-
Ok(RuntimeEvent::PolkadotXcm(event)) => Some(event),
782-
_ => None,
783-
}
784-
}),
785-
Box::new(|runtime_event_encoded: Vec<u8>| {
786-
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
787-
Ok(RuntimeEvent::XcmpQueue(event)) => Some(event),
788-
_ => None,
789-
}
790-
}),
791775
bridging_to_asset_hub_wococo,
792-
WeightLimit::Unlimited,
793-
Some(xcm_config::bridging::XcmBridgeHubRouterFeeAssetId::get()),
794776
|| {
795777
sp_std::vec![
796778
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
@@ -1028,29 +1010,11 @@ mod asset_hub_wococo_tests {
10281010
Runtime,
10291011
AllPalletsWithoutSystem,
10301012
XcmConfig,
1031-
ParachainSystem,
1032-
XcmpQueue,
10331013
LocationToAccountId,
10341014
ToRococoXcmRouterInstance,
10351015
>(
10361016
collator_session_keys(),
1037-
ExistentialDeposit::get(),
1038-
AccountId::from(ALICE),
1039-
Box::new(|runtime_event_encoded: Vec<u8>| {
1040-
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
1041-
Ok(RuntimeEvent::PolkadotXcm(event)) => Some(event),
1042-
_ => None,
1043-
}
1044-
}),
1045-
Box::new(|runtime_event_encoded: Vec<u8>| {
1046-
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
1047-
Ok(RuntimeEvent::XcmpQueue(event)) => Some(event),
1048-
_ => None,
1049-
}
1050-
}),
10511017
with_wococo_flavor_bridging_to_asset_hub_rococo,
1052-
WeightLimit::Unlimited,
1053-
Some(xcm_config::bridging::XcmBridgeHubRouterFeeAssetId::get()),
10541018
|| {
10551019
sp_std::vec![
10561020
UnpaidExecution { weight_limit: Unlimited, check_origin: None },

cumulus/parachains/runtimes/assets/test-utils/src/lib.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,48 @@
1919
pub mod test_cases;
2020
pub mod test_cases_over_bridge;
2121
pub mod xcm_helpers;
22+
23+
use frame_support::traits::ProcessMessageError;
2224
pub use parachains_runtimes_test_utils::*;
25+
use std::fmt::Debug;
26+
27+
use xcm::latest::prelude::*;
28+
use xcm_builder::{CreateMatcher, MatchXcm};
29+
30+
/// Helper function to verify `xcm` contains all relevant instructions expected on destination
31+
/// chain as part of a reserve-asset-transfer.
32+
pub(crate) fn assert_matches_reserve_asset_deposited_instructions<RuntimeCall: Debug>(
33+
xcm: &mut Xcm<RuntimeCall>,
34+
expected_reserve_assets_deposited: &MultiAssets,
35+
expected_beneficiary: &MultiLocation,
36+
) {
37+
let _ = xcm
38+
.0
39+
.matcher()
40+
.skip_inst_while(|inst| !matches!(inst, ReserveAssetDeposited(..)))
41+
.expect("no instruction ReserveAssetDeposited?")
42+
.match_next_inst(|instr| match instr {
43+
ReserveAssetDeposited(reserve_assets) => {
44+
assert_eq!(reserve_assets, expected_reserve_assets_deposited);
45+
Ok(())
46+
},
47+
_ => Err(ProcessMessageError::BadFormat),
48+
})
49+
.expect("expected instruction ReserveAssetDeposited")
50+
.match_next_inst(|instr| match instr {
51+
ClearOrigin => Ok(()),
52+
_ => Err(ProcessMessageError::BadFormat),
53+
})
54+
.expect("expected instruction ClearOrigin")
55+
.match_next_inst(|instr| match instr {
56+
BuyExecution { .. } => Ok(()),
57+
_ => Err(ProcessMessageError::BadFormat),
58+
})
59+
.expect("expected instruction BuyExecution")
60+
.match_next_inst(|instr| match instr {
61+
DepositAsset { assets: _, beneficiary } if beneficiary == expected_beneficiary =>
62+
Ok(()),
63+
_ => Err(ProcessMessageError::BadFormat),
64+
})
65+
.expect("expected instruction DepositAsset");
66+
}

0 commit comments

Comments
 (0)