Skip to content

Commit 28386c8

Browse files
authored
limited_reserve_transfer_assets works from AssetHub (#487)
1 parent cf63835 commit 28386c8

File tree

3 files changed

+41
-35
lines changed

3 files changed

+41
-35
lines changed

modules/pallets/testsuite/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ evm-state-machine = { workspace = true, default-features = true }
5353
subxt-utils = { workspace = true, default-features = true }
5454
ismp-grandpa = { workspace = true, default-features = true }
5555
rs_merkle = { version = "1.5.0"}
56+
log = { workspace = true }
5657

5758
[dependencies.polkadot-sdk]
5859
workspace = true

modules/pallets/testsuite/src/tests/pallet_xcm_gateway.rs

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::runtime::BOB;
2727

2828

2929
const SEND_AMOUNT: u128 = 1000_000_000_0000;
30-
const PARA_ID: u32 = 100;
30+
const PARA_ID: u32 = crate::xcm::SIBLING_PARA_ID;
3131
pub type RelayChainPalletXcm = pallet_xcm::Pallet<relay_chain::Runtime>;
3232

3333
#[test]
@@ -55,7 +55,7 @@ fn should_dispatch_ismp_request_when_assets_are_received_from_assethub() {
5555

5656

5757
ParaB::execute_with(|| {
58-
let dest = Location::new(1, [Parachain(100)]);
58+
let dest = Location::new(1, [Parachain(PARA_ID)]);
5959
let beneficiary: Location = Junctions::X3(Arc::new([
6060
Junction::AccountId32 { network: None, id: ALICE.into() },
6161
Junction::AccountKey20 {
@@ -79,38 +79,37 @@ fn should_dispatch_ismp_request_when_assets_are_received_from_assethub() {
7979
let fee_asset = assets.clone().reanchored(&dest, &context).expect("should reanchor");
8080
let fees = fee_asset.clone();
8181

82-
83-
let xcm = Xcm(vec![
84-
BuyExecution { fees, weight_limit: WeightLimit::Unlimited },
85-
DepositAsset {
86-
assets: Wild(All),
87-
beneficiary,
88-
},
89-
]);
90-
91-
let message = Xcm(vec![
92-
SetFeesMode { jit_withdraw: true },
93-
TransferReserveAsset {
94-
assets: assets.into(),
95-
dest,
96-
xcm,
97-
},
98-
]);
99-
100-
assert_ok!(runtime::PalletXcm::execute(
101-
runtime::RuntimeOrigin::signed(ALICE.into()),
102-
Box::new(VersionedXcm::from(message)),
103-
Weight::MAX
104-
));
105-
106-
/*assert_ok!(runtime::PalletXcm::limited_reserve_transfer_assets(
82+
// let xcm = Xcm(vec![
83+
// BuyExecution { fees, weight_limit: WeightLimit::Unlimited },
84+
// DepositAsset {
85+
// assets: Wild(All),
86+
// beneficiary,
87+
// },
88+
// ]);
89+
90+
// let message = Xcm(vec![
91+
// SetFeesMode { jit_withdraw: true },
92+
// TransferReserveAsset {
93+
// assets: assets.into(),
94+
// dest,
95+
// xcm,
96+
// },
97+
// ]);
98+
99+
// assert_ok!(runtime::PalletXcm::execute(
100+
// runtime::RuntimeOrigin::signed(ALICE.into()),
101+
// Box::new(VersionedXcm::from(message)),
102+
// Weight::MAX
103+
// ));
104+
105+
assert_ok!(runtime::PalletXcm::limited_reserve_transfer_assets(
107106
runtime::RuntimeOrigin::signed(ALICE.into()),
108107
Box::new(dest.into()),
109108
Box::new(beneficiary.into()),
110109
Box::new(vec![(asset_location_on_assethub, SEND_AMOUNT).into()].into()),
111110
0,
112111
WeightLimit::Unlimited,
113-
));*/
112+
));
114113
});
115114

116115

@@ -124,7 +123,7 @@ fn should_dispatch_ismp_request_when_assets_are_received_from_assethub() {
124123
);
125124
dbg!(bobs_balance);
126125

127-
let parachain_account: ParaId = 100u32.into();
126+
let parachain_account: ParaId = PARA_ID.into();
128127
let parachain_account = parachain_account.into_account_truncating();
129128

130129
let alice_balance = <runtime::Assets as Inspect<

modules/pallets/testsuite/src/xcm.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ parameter_types! {
8080
}
8181

8282
parameter_types! {
83-
pub const KsmLocation: Location = Location::parent();
83+
pub const RelayLocation: Location = Location::parent();
8484
pub const RelayNetwork: Option<NetworkId> = None;
8585
pub UniversalLocation: Junctions = Parachain(ParachainInfo::parachain_id().into()).into();
8686
}
8787

8888
parameter_types! {
89-
pub ExternalConsensus: InteriorLocation = [Parachain(100), Parachain(1000)].into();
89+
pub ExternalConsensus: InteriorLocation = [Parachain(SIBLING_PARA_ID), Parachain(1000)].into();
9090
}
9191

9292
pub type LocationToAccountId = (
@@ -210,12 +210,15 @@ impl DmpMessageHandler for DmpMessageExecutor {
210210
}
211211
}
212212

213+
/// 1000-2000 are considered system parachains, so let's use higher para_id
214+
pub const SIBLING_PARA_ID: u32 = 2222;
215+
213216
decl_test_parachain! {
214217
pub struct ParaA {
215218
Runtime = Test,
216219
XcmpMessageHandler = crate::runtime::MsgQueue,
217220
DmpMessageHandler = DmpMessageExecutor,
218-
new_ext = para_ext(100),
221+
new_ext = para_ext(SIBLING_PARA_ID),
219222
}
220223
}
221224

@@ -244,7 +247,7 @@ decl_test_network! {
244247
pub struct MockNet {
245248
relay_chain = Relay,
246249
parachains = vec![
247-
(100, ParaA),
250+
(SIBLING_PARA_ID, ParaA),
248251
(1000, ParaB),
249252
],
250253
}
@@ -272,7 +275,7 @@ parameter_types! {
272275
pub struct TestReserve;
273276
impl ContainsPair<Asset, Location> for TestReserve {
274277
fn contains(asset: &Asset, origin: &Location) -> bool {
275-
println!("TestReserve::contains asset: {asset:?}, origin:{origin:?}");
278+
log::trace!(target: "xcm", "TestReserve::contains asset: {asset:?}, origin:{origin:?}");
276279
let assethub_location = Location::new(1, Parachain(ASSET_HUB_PARA_ID));
277280
&assethub_location == origin
278281
}
@@ -285,7 +288,10 @@ impl staging_xcm_executor::Config for XcmConfig {
285288
type AssetTransactor = LocalAssetTransactor;
286289
type OriginConverter = XcmOriginToCallOrigin;
287290
type IsReserve = TestReserve;
288-
type IsTeleporter = ();
291+
type IsTeleporter = (
292+
// Important setting reflecting AssetHub
293+
parachains_common::xcm_config::ConcreteAssetFromSystem<RelayLocation>,
294+
);
289295
type UniversalLocation = UniversalLocation;
290296
type Barrier = Barrier;
291297
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;

0 commit comments

Comments
 (0)