Skip to content

Commit

Permalink
fix teleport asset destination (broken test); weight unlimited in tel…
Browse files Browse the repository at this point in the history
…eport asset; log events in assethub; genesis funding for sovereign accounts
  • Loading branch information
luispdm committed Oct 14, 2024
1 parent 99d4a66 commit fd03e9b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
3 changes: 3 additions & 0 deletions xcm-simulator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ pub fn para_ext(para_id: u32) -> sp_io::TestExternalities {
(sibling_account_id(PARA_B_ID), INITIAL_BALANCE),
(sibling_account_id(PARA_TELEPORTER_ID), INITIAL_BALANCE),
(sibling_account_id(PARA_LAOSISH_ID), INITIAL_BALANCE),
(sibling_account_id(PARA_ASSETHUB_ID), INITIAL_BALANCE),
],
}
.assimilate_storage(&mut t)
Expand Down Expand Up @@ -194,6 +195,8 @@ pub fn relay_ext() -> sp_io::TestExternalities {
(child_account_id(PARA_A_ID), INITIAL_BALANCE),
(child_account_id(PARA_B_ID), INITIAL_BALANCE),
(child_account_id(PARA_LAOSISH_ID), INITIAL_BALANCE),
(child_account_id(PARA_ASSETHUB_ID), INITIAL_BALANCE),
(child_account_id(PARA_TELEPORTER_ID), INITIAL_BALANCE),
],
}
.assimilate_storage(&mut t)
Expand Down
49 changes: 28 additions & 21 deletions xcm-simulator/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ mod laosish_xcm;

pub type ForeignAssetsCall =
pallet_assets::Call<parachain::Runtime, parachain::ForeignAssetsInstance>;
pub type TeleportAssetsCall =
pallet_assets::Call<parachain_teleporter::Runtime, parachain_teleporter::ForeignAssetsInstance>;
// pub type TeleportAssetsCall =
// pallet_assets::Call<parachain_teleporter::Runtime, parachain_teleporter::ForeignAssetsInstance>;
pub type TrustBackedAssetsCall =
pallet_assets::Call<parachain::Runtime, parachain::TrustBackedAssetsInstance>;

Expand Down Expand Up @@ -697,38 +697,45 @@ fn xcmp_create_foreign_asset() {
fn teleport_para_teleport_to_para_assethub() {
MockNet::reset();

let para_teleporter_native_asset_location =
xcm::v3::Location::new(1, [xcm::v3::Junction::Parachain(PARA_TELEPORTER_ID)]);
// let para_teleporter_native_asset_location =
// xcm::v3::Location::new(1, [xcm::v3::Junction::Parachain(PARA_TELEPORTER_ID)]);

let create_asset =
parachain_teleporter::RuntimeCall::ForeignAssets(TeleportAssetsCall::create {
id: para_teleporter_native_asset_location,
admin: sibling_account_id(PARA_TELEPORTER_ID),
min_balance: 1000,
});
// let create_asset =
// parachain_teleporter::RuntimeCall::ForeignAssets(TeleportAssetsCall::create {
// id: para_teleporter_native_asset_location,
// admin: sibling_account_id(PARA_TELEPORTER_ID),
// min_balance: 1000,
// });

ParaTeleporter::execute_with(|| {
assert_ok!(ParachainTeleporterPalletXcm::send_xcm(
Here,
(Parent, Parachain(PARA_ASSETHUB_ID)),
Xcm(vec![Transact {
origin_kind: OriginKind::Xcm,
require_weight_at_most: Weight::from_parts(INITIAL_BALANCE as u64, 1024 * 1024),
call: create_asset.encode().into(),
}]),
));
// assert_ok!(ParachainTeleporterPalletXcm::send_xcm(
// Here,
// (Parent, Parachain(PARA_ASSETHUB_ID)),
// Xcm(vec![Transact {
// origin_kind: OriginKind::Xcm,
// require_weight_at_most: Weight::from_parts(INITIAL_BALANCE as u64, 1024 * 1024),
// call: create_asset.encode().into(),
// }]),
// ));

let amount = 1_000;

assert_ok!(ParachainTeleporterPalletXcm::limited_teleport_assets(
parachain_teleporter::RuntimeOrigin::signed(ALICE.into()),
Box::new(Parachain(PARA_ASSETHUB_ID).into()),
Box::new((Parent, Parachain(PARA_ASSETHUB_ID)).into()),
Box::new(AccountId32 { network: None, id: ALICE.into() }.into()),
Box::new((Here, amount).into()),
0,
WeightLimit::Limited(Weight::from_parts(INITIAL_BALANCE as u64, 1024 * 1024)),
WeightLimit::Unlimited,
));

assert_eq!(parachain_teleporter::Balances::free_balance(ALICE), INITIAL_BALANCE - amount);
});

AssetHub::execute_with(|| {
log::trace!(
target:"xcm:events",
"{:?}", asset_hub::System::events()
);
});
}

0 comments on commit fd03e9b

Please sign in to comment.