mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 08:41:02 +00:00
Remove xcm::v3 from assets-common nits (#4037)
This PR mainly removes `xcm::v3` stuff from `assets-common` to make it
more generic and facilitate the transition to newer XCM versions. Some
of the implementations here used hard-coded `xcm::v3::Location`, but now
it's up to the runtime to configure according to its needs.
Additional/consequent changes:
- `penpal` runtime uses now `xcm::latest::Location` for `pallet_assets`
as `AssetId`, because we don't care about migrations here
- it pretty much simplify xcm-emulator integration tests, where we don't
need now a lots of boilerplate conversions:
```
v3::Location::try_from(...).expect("conversion works")`
```
- xcm-emulator tests
- split macro `impl_assets_helpers_for_parachain` to the
`impl_assets_helpers_for_parachain` and
`impl_foreign_assets_helpers_for_parachain` (avoids using hard-coded
`xcm::v3::Location`)
This commit is contained in:
+3
@@ -23,3 +23,6 @@ emulated-integration-tests-common = { path = "../../../../common", default-featu
|
||||
asset-hub-rococo-runtime = { path = "../../../../../../runtimes/assets/asset-hub-rococo" }
|
||||
rococo-emulated-chain = { path = "../../../relays/rococo" }
|
||||
testnet-parachains-constants = { path = "../../../../../../runtimes/constants", features = ["rococo"] }
|
||||
|
||||
# Polkadot
|
||||
xcm = { package = "staging-xcm", path = "../../../../../../../../polkadot/xcm", default-features = false }
|
||||
|
||||
+3
-1
@@ -22,7 +22,8 @@ use frame_support::traits::OnInitialize;
|
||||
use emulated_integration_tests_common::{
|
||||
impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain,
|
||||
impl_assets_helpers_for_parachain, impl_assets_helpers_for_system_parachain,
|
||||
impl_xcm_helpers_for_parachain, impls::Parachain, xcm_emulator::decl_test_parachains,
|
||||
impl_foreign_assets_helpers_for_parachain, impl_xcm_helpers_for_parachain, impls::Parachain,
|
||||
xcm_emulator::decl_test_parachains,
|
||||
};
|
||||
use rococo_emulated_chain::Rococo;
|
||||
|
||||
@@ -56,4 +57,5 @@ impl_accounts_helpers_for_parachain!(AssetHubRococo);
|
||||
impl_assert_events_helpers_for_parachain!(AssetHubRococo);
|
||||
impl_assets_helpers_for_system_parachain!(AssetHubRococo, Rococo);
|
||||
impl_assets_helpers_for_parachain!(AssetHubRococo);
|
||||
impl_foreign_assets_helpers_for_parachain!(AssetHubRococo, xcm::v3::Location);
|
||||
impl_xcm_helpers_for_parachain!(AssetHubRococo);
|
||||
|
||||
+3
@@ -23,3 +23,6 @@ emulated-integration-tests-common = { path = "../../../../common", default-featu
|
||||
asset-hub-westend-runtime = { path = "../../../../../../runtimes/assets/asset-hub-westend" }
|
||||
westend-emulated-chain = { path = "../../../relays/westend" }
|
||||
testnet-parachains-constants = { path = "../../../../../../runtimes/constants", features = ["westend"] }
|
||||
|
||||
# Polkadot
|
||||
xcm = { package = "staging-xcm", path = "../../../../../../../../polkadot/xcm", default-features = false }
|
||||
|
||||
+3
-1
@@ -22,7 +22,8 @@ use frame_support::traits::OnInitialize;
|
||||
use emulated_integration_tests_common::{
|
||||
impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain,
|
||||
impl_assets_helpers_for_parachain, impl_assets_helpers_for_system_parachain,
|
||||
impl_xcm_helpers_for_parachain, impls::Parachain, xcm_emulator::decl_test_parachains,
|
||||
impl_foreign_assets_helpers_for_parachain, impl_xcm_helpers_for_parachain, impls::Parachain,
|
||||
xcm_emulator::decl_test_parachains,
|
||||
};
|
||||
use westend_emulated_chain::Westend;
|
||||
|
||||
@@ -56,4 +57,5 @@ impl_accounts_helpers_for_parachain!(AssetHubWestend);
|
||||
impl_assert_events_helpers_for_parachain!(AssetHubWestend);
|
||||
impl_assets_helpers_for_system_parachain!(AssetHubWestend, Westend);
|
||||
impl_assets_helpers_for_parachain!(AssetHubWestend);
|
||||
impl_foreign_assets_helpers_for_parachain!(AssetHubWestend, xcm::v3::Location);
|
||||
impl_xcm_helpers_for_parachain!(AssetHubWestend);
|
||||
|
||||
+2
-14
@@ -17,8 +17,6 @@
|
||||
use frame_support::parameter_types;
|
||||
use sp_core::{sr25519, storage::Storage};
|
||||
|
||||
// Polkadot
|
||||
use xcm::v3::Location;
|
||||
// Cumulus
|
||||
use emulated_integration_tests_common::{
|
||||
accounts, build_genesis_storage, collators, get_account_id_from_seed, SAFE_XCM_VERSION,
|
||||
@@ -79,19 +77,9 @@ pub fn genesis(para_id: u32) -> Storage {
|
||||
foreign_assets: penpal_runtime::ForeignAssetsConfig {
|
||||
assets: vec![
|
||||
// Relay Native asset representation
|
||||
(
|
||||
Location::try_from(RelayLocation::get()).unwrap(),
|
||||
PenpalAssetOwner::get(),
|
||||
true,
|
||||
ED,
|
||||
),
|
||||
(RelayLocation::get(), PenpalAssetOwner::get(), true, ED),
|
||||
// Sufficient AssetHub asset representation
|
||||
(
|
||||
Location::try_from(LocalReservableFromAssetHub::get()).unwrap(),
|
||||
PenpalAssetOwner::get(),
|
||||
true,
|
||||
ED,
|
||||
),
|
||||
(LocalReservableFromAssetHub::get(), PenpalAssetOwner::get(), true, ED),
|
||||
],
|
||||
..Default::default()
|
||||
},
|
||||
|
||||
+4
-1
@@ -26,7 +26,8 @@ use sp_core::Encode;
|
||||
// Cumulus
|
||||
use emulated_integration_tests_common::{
|
||||
impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain,
|
||||
impl_assets_helpers_for_parachain, impl_xcm_helpers_for_parachain,
|
||||
impl_assets_helpers_for_parachain, impl_foreign_assets_helpers_for_parachain,
|
||||
impl_xcm_helpers_for_parachain,
|
||||
impls::{NetworkId, Parachain},
|
||||
xcm_emulator::decl_test_parachains,
|
||||
};
|
||||
@@ -87,6 +88,8 @@ impl_accounts_helpers_for_parachain!(PenpalB);
|
||||
impl_assert_events_helpers_for_parachain!(PenpalA);
|
||||
impl_assert_events_helpers_for_parachain!(PenpalB);
|
||||
impl_assets_helpers_for_parachain!(PenpalA);
|
||||
impl_foreign_assets_helpers_for_parachain!(PenpalA, xcm::latest::Location);
|
||||
impl_assets_helpers_for_parachain!(PenpalB);
|
||||
impl_foreign_assets_helpers_for_parachain!(PenpalB, xcm::latest::Location);
|
||||
impl_xcm_helpers_for_parachain!(PenpalA);
|
||||
impl_xcm_helpers_for_parachain!(PenpalB);
|
||||
|
||||
@@ -38,9 +38,7 @@ pub use polkadot_runtime_parachains::{
|
||||
inclusion::{AggregateMessageOrigin, UmpQueueId},
|
||||
};
|
||||
pub use xcm::{
|
||||
prelude::{Location, OriginKind, Outcome, VersionedXcm, XcmVersion},
|
||||
v3,
|
||||
v4::Error as XcmError,
|
||||
prelude::{Location, OriginKind, Outcome, VersionedXcm, XcmError, XcmVersion},
|
||||
DoubleEncoded,
|
||||
};
|
||||
|
||||
@@ -696,81 +694,9 @@ macro_rules! impl_assets_helpers_for_system_parachain {
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! impl_assets_helpers_for_parachain {
|
||||
( $chain:ident) => {
|
||||
($chain:ident) => {
|
||||
$crate::impls::paste::paste! {
|
||||
impl<N: $crate::impls::Network> $chain<N> {
|
||||
/// Create foreign assets using sudo `ForeignAssets::force_create()`
|
||||
pub fn force_create_foreign_asset(
|
||||
id: $crate::impls::v3::Location,
|
||||
owner: $crate::impls::AccountId,
|
||||
is_sufficient: bool,
|
||||
min_balance: u128,
|
||||
prefund_accounts: Vec<($crate::impls::AccountId, u128)>,
|
||||
) {
|
||||
use $crate::impls::Inspect;
|
||||
let sudo_origin = <$chain<N> as $crate::impls::Chain>::RuntimeOrigin::root();
|
||||
<Self as $crate::impls::TestExt>::execute_with(|| {
|
||||
$crate::impls::assert_ok!(
|
||||
<Self as [<$chain ParaPallet>]>::ForeignAssets::force_create(
|
||||
sudo_origin,
|
||||
id.clone(),
|
||||
owner.clone().into(),
|
||||
is_sufficient,
|
||||
min_balance,
|
||||
)
|
||||
);
|
||||
assert!(<Self as [<$chain ParaPallet>]>::ForeignAssets::asset_exists(id.clone()));
|
||||
type RuntimeEvent<N> = <$chain<N> as $crate::impls::Chain>::RuntimeEvent;
|
||||
$crate::impls::assert_expected_events!(
|
||||
Self,
|
||||
vec![
|
||||
RuntimeEvent::<N>::ForeignAssets(
|
||||
$crate::impls::pallet_assets::Event::ForceCreated {
|
||||
asset_id,
|
||||
..
|
||||
}
|
||||
) => { asset_id: *asset_id == id, },
|
||||
]
|
||||
);
|
||||
});
|
||||
for (beneficiary, amount) in prefund_accounts.into_iter() {
|
||||
let signed_origin =
|
||||
<$chain<N> as $crate::impls::Chain>::RuntimeOrigin::signed(owner.clone());
|
||||
Self::mint_foreign_asset(signed_origin, id.clone(), beneficiary, amount);
|
||||
}
|
||||
}
|
||||
|
||||
/// Mint assets making use of the ForeignAssets pallet-assets instance
|
||||
pub fn mint_foreign_asset(
|
||||
signed_origin: <Self as $crate::impls::Chain>::RuntimeOrigin,
|
||||
id: $crate::impls::v3::Location,
|
||||
beneficiary: $crate::impls::AccountId,
|
||||
amount_to_mint: u128,
|
||||
) {
|
||||
<Self as $crate::impls::TestExt>::execute_with(|| {
|
||||
$crate::impls::assert_ok!(<Self as [<$chain ParaPallet>]>::ForeignAssets::mint(
|
||||
signed_origin,
|
||||
id.clone().into(),
|
||||
beneficiary.clone().into(),
|
||||
amount_to_mint
|
||||
));
|
||||
|
||||
type RuntimeEvent<N> = <$chain<N> as $crate::impls::Chain>::RuntimeEvent;
|
||||
|
||||
$crate::impls::assert_expected_events!(
|
||||
Self,
|
||||
vec![
|
||||
RuntimeEvent::<N>::ForeignAssets(
|
||||
$crate::impls::pallet_assets::Event::Issued { asset_id, owner, amount }
|
||||
) => {
|
||||
asset_id: *asset_id == id,
|
||||
owner: *owner == beneficiary.clone().into(),
|
||||
amount: *amount == amount_to_mint,
|
||||
},
|
||||
]
|
||||
);
|
||||
});
|
||||
}
|
||||
/// Create assets using sudo `Assets::force_create()`
|
||||
pub fn force_create_asset(
|
||||
id: u32,
|
||||
@@ -863,10 +789,92 @@ macro_rules! impl_assets_helpers_for_parachain {
|
||||
.encode()
|
||||
.into()
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! impl_foreign_assets_helpers_for_parachain {
|
||||
($chain:ident, $asset_id_type:ty) => {
|
||||
$crate::impls::paste::paste! {
|
||||
impl<N: $crate::impls::Network> $chain<N> {
|
||||
/// Create foreign assets using sudo `ForeignAssets::force_create()`
|
||||
pub fn force_create_foreign_asset(
|
||||
id: $asset_id_type,
|
||||
owner: $crate::impls::AccountId,
|
||||
is_sufficient: bool,
|
||||
min_balance: u128,
|
||||
prefund_accounts: Vec<($crate::impls::AccountId, u128)>,
|
||||
) {
|
||||
use $crate::impls::Inspect;
|
||||
let sudo_origin = <$chain<N> as $crate::impls::Chain>::RuntimeOrigin::root();
|
||||
<Self as $crate::impls::TestExt>::execute_with(|| {
|
||||
$crate::impls::assert_ok!(
|
||||
<Self as [<$chain ParaPallet>]>::ForeignAssets::force_create(
|
||||
sudo_origin,
|
||||
id.clone(),
|
||||
owner.clone().into(),
|
||||
is_sufficient,
|
||||
min_balance,
|
||||
)
|
||||
);
|
||||
assert!(<Self as [<$chain ParaPallet>]>::ForeignAssets::asset_exists(id.clone()));
|
||||
type RuntimeEvent<N> = <$chain<N> as $crate::impls::Chain>::RuntimeEvent;
|
||||
$crate::impls::assert_expected_events!(
|
||||
Self,
|
||||
vec![
|
||||
RuntimeEvent::<N>::ForeignAssets(
|
||||
$crate::impls::pallet_assets::Event::ForceCreated {
|
||||
asset_id,
|
||||
..
|
||||
}
|
||||
) => { asset_id: *asset_id == id, },
|
||||
]
|
||||
);
|
||||
});
|
||||
for (beneficiary, amount) in prefund_accounts.into_iter() {
|
||||
let signed_origin =
|
||||
<$chain<N> as $crate::impls::Chain>::RuntimeOrigin::signed(owner.clone());
|
||||
Self::mint_foreign_asset(signed_origin, id.clone(), beneficiary, amount);
|
||||
}
|
||||
}
|
||||
|
||||
/// Mint assets making use of the ForeignAssets pallet-assets instance
|
||||
pub fn mint_foreign_asset(
|
||||
signed_origin: <Self as $crate::impls::Chain>::RuntimeOrigin,
|
||||
id: $asset_id_type,
|
||||
beneficiary: $crate::impls::AccountId,
|
||||
amount_to_mint: u128,
|
||||
) {
|
||||
<Self as $crate::impls::TestExt>::execute_with(|| {
|
||||
$crate::impls::assert_ok!(<Self as [<$chain ParaPallet>]>::ForeignAssets::mint(
|
||||
signed_origin,
|
||||
id.clone().into(),
|
||||
beneficiary.clone().into(),
|
||||
amount_to_mint
|
||||
));
|
||||
|
||||
type RuntimeEvent<N> = <$chain<N> as $crate::impls::Chain>::RuntimeEvent;
|
||||
|
||||
$crate::impls::assert_expected_events!(
|
||||
Self,
|
||||
vec![
|
||||
RuntimeEvent::<N>::ForeignAssets(
|
||||
$crate::impls::pallet_assets::Event::Issued { asset_id, owner, amount }
|
||||
) => {
|
||||
asset_id: *asset_id == id,
|
||||
owner: *owner == beneficiary.clone().into(),
|
||||
amount: *amount == amount_to_mint,
|
||||
},
|
||||
]
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/// Returns the encoded call for `create` from the foreign assets pallet
|
||||
pub fn create_foreign_asset_call(
|
||||
asset_id: $crate::impls::v3::Location,
|
||||
asset_id: $asset_id_type,
|
||||
min_balance: $crate::impls::Balance,
|
||||
admin: $crate::impls::AccountId,
|
||||
) -> $crate::impls::DoubleEncoded<()> {
|
||||
|
||||
+68
-48
@@ -137,14 +137,13 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
|
||||
let destination = AssetHubRococo::sibling_location_of(PenpalA::para_id());
|
||||
let sender = AssetHubRococoSender::get();
|
||||
let native_amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 10000;
|
||||
let native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let native_asset_location = RelayLocation::get();
|
||||
let receiver = PenpalAReceiver::get();
|
||||
let assets_owner = PenpalAssetOwner::get();
|
||||
// Foreign asset used: bridged WND
|
||||
let foreign_amount_to_send = ASSET_HUB_ROCOCO_ED * 10_000_000;
|
||||
let wnd_at_rococo_parachains =
|
||||
v3::Location::new(2, [v3::Junction::GlobalConsensus(v3::NetworkId::Westend)]);
|
||||
let wnd_at_rococo_parachains_latest: Location = wnd_at_rococo_parachains.try_into().unwrap();
|
||||
Location::new(2, [Junction::GlobalConsensus(NetworkId::Westend)]);
|
||||
|
||||
// Configure destination chain to trust AH as reserve of WND
|
||||
PenpalA::execute_with(|| {
|
||||
@@ -157,14 +156,14 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
|
||||
));
|
||||
});
|
||||
PenpalA::force_create_foreign_asset(
|
||||
wnd_at_rococo_parachains,
|
||||
wnd_at_rococo_parachains.clone(),
|
||||
assets_owner.clone(),
|
||||
false,
|
||||
ASSET_MIN_BALANCE,
|
||||
vec![],
|
||||
);
|
||||
AssetHubRococo::force_create_foreign_asset(
|
||||
wnd_at_rococo_parachains,
|
||||
wnd_at_rococo_parachains.clone().try_into().unwrap(),
|
||||
assets_owner.clone(),
|
||||
false,
|
||||
ASSET_MIN_BALANCE,
|
||||
@@ -172,7 +171,7 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
|
||||
);
|
||||
AssetHubRococo::mint_foreign_asset(
|
||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(assets_owner),
|
||||
wnd_at_rococo_parachains,
|
||||
wnd_at_rococo_parachains.clone().try_into().unwrap(),
|
||||
sender.clone(),
|
||||
foreign_amount_to_send * 2,
|
||||
);
|
||||
@@ -180,7 +179,7 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
|
||||
// Assets to send
|
||||
let assets: Vec<Asset> = vec![
|
||||
(Parent, native_amount_to_send).into(),
|
||||
(wnd_at_rococo_parachains_latest, foreign_amount_to_send).into(),
|
||||
(wnd_at_rococo_parachains.clone(), foreign_amount_to_send).into(),
|
||||
];
|
||||
let fee_asset_id = AssetId(Parent.into());
|
||||
let fee_asset_item = assets.iter().position(|a| a.id == fee_asset_id).unwrap() as u32;
|
||||
@@ -204,15 +203,18 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
|
||||
let sender_balance_before = test.sender.balance;
|
||||
let sender_wnds_before = AssetHubRococo::execute_with(|| {
|
||||
type ForeignAssets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
wnd_at_rococo_parachains.clone().try_into().unwrap(),
|
||||
&sender,
|
||||
)
|
||||
});
|
||||
let receiver_assets_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(native_asset_location.into(), &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(native_asset_location.clone(), &receiver)
|
||||
});
|
||||
let receiver_wnds_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains, &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains.clone(), &receiver)
|
||||
});
|
||||
|
||||
// Set assertions and dispatchables
|
||||
@@ -225,7 +227,10 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
|
||||
let sender_balance_after = test.sender.balance;
|
||||
let sender_wnds_after = AssetHubRococo::execute_with(|| {
|
||||
type ForeignAssets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
wnd_at_rococo_parachains.clone().try_into().unwrap(),
|
||||
&sender,
|
||||
)
|
||||
});
|
||||
let receiver_assets_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
@@ -262,14 +267,13 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
|
||||
let destination = PenpalA::sibling_location_of(AssetHubRococo::para_id());
|
||||
let sender = PenpalASender::get();
|
||||
let native_amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 10000;
|
||||
let native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let native_asset_location = RelayLocation::get();
|
||||
let assets_owner = PenpalAssetOwner::get();
|
||||
|
||||
// Foreign asset used: bridged WND
|
||||
let foreign_amount_to_send = ASSET_HUB_ROCOCO_ED * 10_000_000;
|
||||
let wnd_at_rococo_parachains =
|
||||
v3::Location::new(2, [v3::Junction::GlobalConsensus(v3::NetworkId::Westend)]);
|
||||
let wnd_at_rococo_parachains_latest: Location = wnd_at_rococo_parachains.try_into().unwrap();
|
||||
Location::new(2, [Junction::GlobalConsensus(NetworkId::Westend)]);
|
||||
|
||||
// Configure destination chain to trust AH as reserve of WND
|
||||
PenpalA::execute_with(|| {
|
||||
@@ -282,14 +286,14 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
|
||||
));
|
||||
});
|
||||
PenpalA::force_create_foreign_asset(
|
||||
wnd_at_rococo_parachains,
|
||||
wnd_at_rococo_parachains.clone(),
|
||||
assets_owner.clone(),
|
||||
false,
|
||||
ASSET_MIN_BALANCE,
|
||||
vec![],
|
||||
);
|
||||
AssetHubRococo::force_create_foreign_asset(
|
||||
wnd_at_rococo_parachains,
|
||||
wnd_at_rococo_parachains.clone().try_into().unwrap(),
|
||||
assets_owner.clone(),
|
||||
false,
|
||||
ASSET_MIN_BALANCE,
|
||||
@@ -299,13 +303,13 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
|
||||
// fund Parachain's sender account
|
||||
PenpalA::mint_foreign_asset(
|
||||
<PenpalA as Chain>::RuntimeOrigin::signed(assets_owner.clone()),
|
||||
native_asset_location,
|
||||
native_asset_location.clone(),
|
||||
sender.clone(),
|
||||
native_amount_to_send * 2,
|
||||
);
|
||||
PenpalA::mint_foreign_asset(
|
||||
<PenpalA as Chain>::RuntimeOrigin::signed(assets_owner.clone()),
|
||||
wnd_at_rococo_parachains,
|
||||
wnd_at_rococo_parachains.clone(),
|
||||
sender.clone(),
|
||||
foreign_amount_to_send * 2,
|
||||
);
|
||||
@@ -322,7 +326,7 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
|
||||
)]);
|
||||
AssetHubRococo::mint_foreign_asset(
|
||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(assets_owner),
|
||||
wnd_at_rococo_parachains,
|
||||
wnd_at_rococo_parachains.clone().try_into().unwrap(),
|
||||
sov_penpal_on_ahr,
|
||||
foreign_amount_to_send * 2,
|
||||
);
|
||||
@@ -330,7 +334,7 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
|
||||
// Assets to send
|
||||
let assets: Vec<Asset> = vec![
|
||||
(Parent, native_amount_to_send).into(),
|
||||
(wnd_at_rococo_parachains_latest, foreign_amount_to_send).into(),
|
||||
(wnd_at_rococo_parachains.clone(), foreign_amount_to_send).into(),
|
||||
];
|
||||
let fee_asset_id = AssetId(Parent.into());
|
||||
let fee_asset_item = assets.iter().position(|a| a.id == fee_asset_id).unwrap() as u32;
|
||||
@@ -353,16 +357,19 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
|
||||
// Query initial balances
|
||||
let sender_native_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(native_asset_location, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(native_asset_location.clone(), &sender)
|
||||
});
|
||||
let sender_wnds_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains.clone(), &sender)
|
||||
});
|
||||
let receiver_native_before = test.receiver.balance;
|
||||
let receiver_wnds_before = AssetHubRococo::execute_with(|| {
|
||||
type ForeignAssets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains, &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
wnd_at_rococo_parachains.clone().try_into().unwrap(),
|
||||
&receiver,
|
||||
)
|
||||
});
|
||||
|
||||
// Set assertions and dispatchables
|
||||
@@ -378,12 +385,15 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
|
||||
});
|
||||
let sender_wnds_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains.clone(), &sender)
|
||||
});
|
||||
let receiver_native_after = test.receiver.balance;
|
||||
let receiver_wnds_after = AssetHubRococo::execute_with(|| {
|
||||
type ForeignAssets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains, &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
wnd_at_rococo_parachains.try_into().unwrap(),
|
||||
&receiver,
|
||||
)
|
||||
});
|
||||
|
||||
// Sender's balance is reduced by amount sent plus delivery fees
|
||||
@@ -412,8 +422,7 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
|
||||
let sender = PenpalASender::get();
|
||||
let roc_to_send: Balance = ROCOCO_ED * 10000;
|
||||
let assets_owner = PenpalAssetOwner::get();
|
||||
let roc_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let roc_location_latest: Location = roc_location.try_into().unwrap();
|
||||
let roc_location = RelayLocation::get();
|
||||
let sender_as_seen_by_ah = AssetHubRococo::sibling_location_of(PenpalA::para_id());
|
||||
let sov_of_sender_on_ah = AssetHubRococo::sovereign_account_id_of(sender_as_seen_by_ah);
|
||||
let receiver_as_seen_by_ah = AssetHubRococo::sibling_location_of(PenpalB::para_id());
|
||||
@@ -433,24 +442,23 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
|
||||
|
||||
// Register WND as foreign asset and transfer it around the Rococo ecosystem
|
||||
let wnd_at_rococo_parachains =
|
||||
v3::Location::new(2, [v3::Junction::GlobalConsensus(v3::NetworkId::Westend)]);
|
||||
let wnd_at_rococo_parachains_latest: Location = wnd_at_rococo_parachains.try_into().unwrap();
|
||||
Location::new(2, [Junction::GlobalConsensus(NetworkId::Westend)]);
|
||||
AssetHubRococo::force_create_foreign_asset(
|
||||
wnd_at_rococo_parachains,
|
||||
wnd_at_rococo_parachains.clone().try_into().unwrap(),
|
||||
assets_owner.clone(),
|
||||
false,
|
||||
ASSET_MIN_BALANCE,
|
||||
vec![],
|
||||
);
|
||||
PenpalA::force_create_foreign_asset(
|
||||
wnd_at_rococo_parachains,
|
||||
wnd_at_rococo_parachains.clone(),
|
||||
assets_owner.clone(),
|
||||
false,
|
||||
ASSET_MIN_BALANCE,
|
||||
vec![],
|
||||
);
|
||||
PenpalB::force_create_foreign_asset(
|
||||
wnd_at_rococo_parachains,
|
||||
wnd_at_rococo_parachains.clone(),
|
||||
assets_owner.clone(),
|
||||
false,
|
||||
ASSET_MIN_BALANCE,
|
||||
@@ -460,13 +468,13 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
|
||||
// fund Parachain's sender account
|
||||
PenpalA::mint_foreign_asset(
|
||||
<PenpalA as Chain>::RuntimeOrigin::signed(assets_owner.clone()),
|
||||
roc_location,
|
||||
roc_location.clone(),
|
||||
sender.clone(),
|
||||
roc_to_send * 2,
|
||||
);
|
||||
PenpalA::mint_foreign_asset(
|
||||
<PenpalA as Chain>::RuntimeOrigin::signed(assets_owner.clone()),
|
||||
wnd_at_rococo_parachains,
|
||||
wnd_at_rococo_parachains.clone(),
|
||||
sender.clone(),
|
||||
wnd_to_send * 2,
|
||||
);
|
||||
@@ -474,7 +482,7 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
|
||||
AssetHubRococo::fund_accounts(vec![(sov_of_sender_on_ah.clone().into(), roc_to_send * 2)]);
|
||||
AssetHubRococo::mint_foreign_asset(
|
||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(assets_owner),
|
||||
wnd_at_rococo_parachains,
|
||||
wnd_at_rococo_parachains.clone().try_into().unwrap(),
|
||||
sov_of_sender_on_ah.clone(),
|
||||
wnd_to_send * 2,
|
||||
);
|
||||
@@ -484,10 +492,10 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
|
||||
|
||||
// Assets to send
|
||||
let assets: Vec<Asset> = vec![
|
||||
(roc_location_latest.clone(), roc_to_send).into(),
|
||||
(wnd_at_rococo_parachains_latest, wnd_to_send).into(),
|
||||
(roc_location.clone(), roc_to_send).into(),
|
||||
(wnd_at_rococo_parachains.clone(), wnd_to_send).into(),
|
||||
];
|
||||
let fee_asset_id: AssetId = roc_location_latest.into();
|
||||
let fee_asset_id: AssetId = roc_location.clone().into();
|
||||
let fee_asset_item = assets.iter().position(|a| a.id == fee_asset_id).unwrap() as u32;
|
||||
|
||||
// Init Test
|
||||
@@ -508,31 +516,37 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
|
||||
// Query initial balances
|
||||
let sender_rocs_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_location, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_location.clone(), &sender)
|
||||
});
|
||||
let sender_wnds_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains.clone(), &sender)
|
||||
});
|
||||
let rocs_in_sender_reserve_on_ahr_before =
|
||||
<AssetHubRococo as Chain>::account_data_of(sov_of_sender_on_ah.clone()).free;
|
||||
let wnds_in_sender_reserve_on_ahr_before = AssetHubRococo::execute_with(|| {
|
||||
type Assets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
|
||||
<Assets as Inspect<_>>::balance(wnd_at_rococo_parachains, &sov_of_sender_on_ah)
|
||||
<Assets as Inspect<_>>::balance(
|
||||
wnd_at_rococo_parachains.clone().try_into().unwrap(),
|
||||
&sov_of_sender_on_ah,
|
||||
)
|
||||
});
|
||||
let rocs_in_receiver_reserve_on_ahr_before =
|
||||
<AssetHubRococo as Chain>::account_data_of(sov_of_receiver_on_ah.clone()).free;
|
||||
let wnds_in_receiver_reserve_on_ahr_before = AssetHubRococo::execute_with(|| {
|
||||
type Assets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
|
||||
<Assets as Inspect<_>>::balance(wnd_at_rococo_parachains, &sov_of_receiver_on_ah)
|
||||
<Assets as Inspect<_>>::balance(
|
||||
wnd_at_rococo_parachains.clone().try_into().unwrap(),
|
||||
&sov_of_receiver_on_ah,
|
||||
)
|
||||
});
|
||||
let receiver_rocs_before = PenpalB::execute_with(|| {
|
||||
type ForeignAssets = <PenpalB as PenpalBPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_location, &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_location.clone(), &receiver)
|
||||
});
|
||||
let receiver_wnds_before = PenpalB::execute_with(|| {
|
||||
type ForeignAssets = <PenpalB as PenpalBPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains, &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains.clone(), &receiver)
|
||||
});
|
||||
|
||||
// Set assertions and dispatchables
|
||||
@@ -545,21 +559,27 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
|
||||
// Query final balances
|
||||
let sender_rocs_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_location, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_location.clone(), &sender)
|
||||
});
|
||||
let sender_wnds_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains.clone(), &sender)
|
||||
});
|
||||
let wnds_in_sender_reserve_on_ahr_after = AssetHubRococo::execute_with(|| {
|
||||
type Assets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
|
||||
<Assets as Inspect<_>>::balance(wnd_at_rococo_parachains, &sov_of_sender_on_ah)
|
||||
<Assets as Inspect<_>>::balance(
|
||||
wnd_at_rococo_parachains.clone().try_into().unwrap(),
|
||||
&sov_of_sender_on_ah,
|
||||
)
|
||||
});
|
||||
let rocs_in_sender_reserve_on_ahr_after =
|
||||
<AssetHubRococo as Chain>::account_data_of(sov_of_sender_on_ah).free;
|
||||
let wnds_in_receiver_reserve_on_ahr_after = AssetHubRococo::execute_with(|| {
|
||||
type Assets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
|
||||
<Assets as Inspect<_>>::balance(wnd_at_rococo_parachains, &sov_of_receiver_on_ah)
|
||||
<Assets as Inspect<_>>::balance(
|
||||
wnd_at_rococo_parachains.clone().try_into().unwrap(),
|
||||
&sov_of_receiver_on_ah,
|
||||
)
|
||||
});
|
||||
let rocs_in_receiver_reserve_on_ahr_after =
|
||||
<AssetHubRococo as Chain>::account_data_of(sov_of_receiver_on_ah).free;
|
||||
|
||||
+41
-43
@@ -47,7 +47,7 @@ fn para_to_relay_sender_assertions(t: ParaToRelayTest) {
|
||||
RuntimeEvent::ForeignAssets(
|
||||
pallet_assets::Event::Burned { asset_id, owner, balance, .. }
|
||||
) => {
|
||||
asset_id: *asset_id == v3::Location::try_from(RelayLocation::get()).unwrap(),
|
||||
asset_id: *asset_id == RelayLocation::get(),
|
||||
owner: *owner == t.sender.account_id,
|
||||
balance: *balance == t.args.amount,
|
||||
},
|
||||
@@ -106,6 +106,7 @@ pub fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) {
|
||||
|
||||
pub fn system_para_to_para_receiver_assertions(t: SystemParaToParaTest) {
|
||||
type RuntimeEvent = <PenpalA as Chain>::RuntimeEvent;
|
||||
|
||||
PenpalA::assert_xcmp_queue_success(None);
|
||||
for asset in t.args.assets.into_inner().into_iter() {
|
||||
let expected_id = asset.id.0.try_into().unwrap();
|
||||
@@ -125,7 +126,7 @@ pub fn para_to_system_para_sender_assertions(t: ParaToSystemParaTest) {
|
||||
type RuntimeEvent = <PenpalA as Chain>::RuntimeEvent;
|
||||
PenpalA::assert_xcm_pallet_attempted_complete(None);
|
||||
for asset in t.args.assets.into_inner().into_iter() {
|
||||
let expected_id = asset.id.0.try_into().unwrap();
|
||||
let expected_id = asset.id.0;
|
||||
let asset_amount = if let Fungible(a) = asset.fun { Some(a) } else { None }.unwrap();
|
||||
assert_expected_events!(
|
||||
PenpalA,
|
||||
@@ -265,9 +266,8 @@ fn system_para_to_para_assets_sender_assertions(t: SystemParaToParaTest) {
|
||||
|
||||
fn para_to_system_para_assets_sender_assertions(t: ParaToSystemParaTest) {
|
||||
type RuntimeEvent = <PenpalA as Chain>::RuntimeEvent;
|
||||
let system_para_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let reservable_asset_location =
|
||||
v3::Location::try_from(PenpalLocalReservableFromAssetHub::get()).unwrap();
|
||||
let system_para_native_asset_location = RelayLocation::get();
|
||||
let reservable_asset_location = PenpalLocalReservableFromAssetHub::get();
|
||||
PenpalA::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(864_610_000, 8799)));
|
||||
assert_expected_events!(
|
||||
PenpalA,
|
||||
@@ -297,14 +297,13 @@ fn para_to_system_para_assets_sender_assertions(t: ParaToSystemParaTest) {
|
||||
|
||||
fn system_para_to_para_assets_receiver_assertions(t: SystemParaToParaTest) {
|
||||
type RuntimeEvent = <PenpalA as Chain>::RuntimeEvent;
|
||||
let system_para_asset_location =
|
||||
v3::Location::try_from(PenpalLocalReservableFromAssetHub::get()).unwrap();
|
||||
let system_para_asset_location = PenpalLocalReservableFromAssetHub::get();
|
||||
PenpalA::assert_xcmp_queue_success(None);
|
||||
assert_expected_events!(
|
||||
PenpalA,
|
||||
vec![
|
||||
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, .. }) => {
|
||||
asset_id: *asset_id == v3::Location::try_from(RelayLocation::get()).unwrap(),
|
||||
asset_id: *asset_id == RelayLocation::get(),
|
||||
owner: *owner == t.receiver.account_id,
|
||||
},
|
||||
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, amount }) => {
|
||||
@@ -356,7 +355,7 @@ fn relay_to_para_assets_receiver_assertions(t: RelayToParaTest) {
|
||||
PenpalA,
|
||||
vec![
|
||||
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, .. }) => {
|
||||
asset_id: *asset_id == v3::Location::try_from(RelayLocation::get()).unwrap(),
|
||||
asset_id: *asset_id == RelayLocation::get(),
|
||||
owner: *owner == t.receiver.account_id,
|
||||
},
|
||||
RuntimeEvent::MessageQueue(
|
||||
@@ -576,7 +575,7 @@ fn reserve_transfer_native_asset_from_relay_to_para() {
|
||||
let amount_to_send: Balance = ROCOCO_ED * 1000;
|
||||
|
||||
// Init values fot Parachain
|
||||
let relay_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let relay_native_asset_location = RelayLocation::get();
|
||||
let receiver = PenpalAReceiver::get();
|
||||
|
||||
// Init Test
|
||||
@@ -591,7 +590,7 @@ fn reserve_transfer_native_asset_from_relay_to_para() {
|
||||
let sender_balance_before = test.sender.balance;
|
||||
let receiver_assets_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location.into(), &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location.clone(), &receiver)
|
||||
});
|
||||
|
||||
// Set assertions and dispatchables
|
||||
@@ -604,7 +603,7 @@ fn reserve_transfer_native_asset_from_relay_to_para() {
|
||||
let sender_balance_after = test.sender.balance;
|
||||
let receiver_assets_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location.into(), &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location, &receiver)
|
||||
});
|
||||
|
||||
// Sender's balance is reduced by amount sent plus delivery fees
|
||||
@@ -626,12 +625,12 @@ fn reserve_transfer_native_asset_from_para_to_relay() {
|
||||
let amount_to_send: Balance = ROCOCO_ED * 1000;
|
||||
let assets: Assets = (Parent, amount_to_send).into();
|
||||
let asset_owner = PenpalAssetOwner::get();
|
||||
let relay_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let relay_native_asset_location = RelayLocation::get();
|
||||
|
||||
// fund Parachain's sender account
|
||||
PenpalA::mint_foreign_asset(
|
||||
<PenpalA as Chain>::RuntimeOrigin::signed(asset_owner),
|
||||
relay_native_asset_location,
|
||||
relay_native_asset_location.clone(),
|
||||
sender.clone(),
|
||||
amount_to_send * 2,
|
||||
);
|
||||
@@ -662,7 +661,7 @@ fn reserve_transfer_native_asset_from_para_to_relay() {
|
||||
// Query initial balances
|
||||
let sender_assets_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location.into(), &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location.clone(), &sender)
|
||||
});
|
||||
let receiver_balance_before = test.receiver.balance;
|
||||
|
||||
@@ -675,7 +674,7 @@ fn reserve_transfer_native_asset_from_para_to_relay() {
|
||||
// Query final balances
|
||||
let sender_assets_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location.into(), &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location, &sender)
|
||||
});
|
||||
let receiver_balance_after = test.receiver.balance;
|
||||
|
||||
@@ -702,7 +701,7 @@ fn reserve_transfer_native_asset_from_system_para_to_para() {
|
||||
let assets: Assets = (Parent, amount_to_send).into();
|
||||
|
||||
// Init values for Parachain
|
||||
let system_para_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let system_para_native_asset_location = RelayLocation::get();
|
||||
let receiver = PenpalAReceiver::get();
|
||||
|
||||
// Init Test
|
||||
@@ -724,7 +723,7 @@ fn reserve_transfer_native_asset_from_system_para_to_para() {
|
||||
let sender_balance_before = test.sender.balance;
|
||||
let receiver_assets_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_native_asset_location.into(), &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_native_asset_location.clone(), &receiver)
|
||||
});
|
||||
|
||||
// Set assertions and dispatchables
|
||||
@@ -758,13 +757,13 @@ fn reserve_transfer_native_asset_from_para_to_system_para() {
|
||||
let sender = PenpalASender::get();
|
||||
let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 10000;
|
||||
let assets: Assets = (Parent, amount_to_send).into();
|
||||
let system_para_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let system_para_native_asset_location = RelayLocation::get();
|
||||
let asset_owner = PenpalAssetOwner::get();
|
||||
|
||||
// fund Parachain's sender account
|
||||
PenpalA::mint_foreign_asset(
|
||||
<PenpalA as Chain>::RuntimeOrigin::signed(asset_owner),
|
||||
system_para_native_asset_location,
|
||||
system_para_native_asset_location.clone(),
|
||||
sender.clone(),
|
||||
amount_to_send * 2,
|
||||
);
|
||||
@@ -795,7 +794,7 @@ fn reserve_transfer_native_asset_from_para_to_system_para() {
|
||||
// Query initial balances
|
||||
let sender_assets_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_native_asset_location, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_native_asset_location.clone(), &sender)
|
||||
});
|
||||
let receiver_balance_before = test.receiver.balance;
|
||||
|
||||
@@ -863,9 +862,8 @@ fn reserve_transfer_assets_from_system_para_to_para() {
|
||||
|
||||
// Init values for Parachain
|
||||
let receiver = PenpalAReceiver::get();
|
||||
let system_para_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let system_para_foreign_asset_location =
|
||||
v3::Location::try_from(PenpalLocalReservableFromAssetHub::get()).unwrap();
|
||||
let system_para_native_asset_location = RelayLocation::get();
|
||||
let system_para_foreign_asset_location = PenpalLocalReservableFromAssetHub::get();
|
||||
|
||||
// Init Test
|
||||
let para_test_args = TestContext {
|
||||
@@ -890,11 +888,14 @@ fn reserve_transfer_assets_from_system_para_to_para() {
|
||||
});
|
||||
let receiver_system_native_assets_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_native_asset_location, &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_native_asset_location.clone(), &receiver)
|
||||
});
|
||||
let receiver_foreign_assets_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_foreign_asset_location, &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
system_para_foreign_asset_location.clone(),
|
||||
&receiver,
|
||||
)
|
||||
});
|
||||
|
||||
// Set assertions and dispatchables
|
||||
@@ -911,7 +912,7 @@ fn reserve_transfer_assets_from_system_para_to_para() {
|
||||
});
|
||||
let receiver_system_native_assets_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_native_asset_location, &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_native_asset_location.clone(), &receiver)
|
||||
});
|
||||
let receiver_foreign_assets_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
@@ -949,13 +950,11 @@ fn reserve_transfer_assets_from_para_to_system_para() {
|
||||
let asset_amount_to_send = ASSET_HUB_ROCOCO_ED * 10000;
|
||||
let penpal_asset_owner = PenpalAssetOwner::get();
|
||||
let penpal_asset_owner_signer = <PenpalA as Chain>::RuntimeOrigin::signed(penpal_asset_owner);
|
||||
let asset_location_on_penpal =
|
||||
v3::Location::try_from(PenpalLocalReservableFromAssetHub::get()).unwrap();
|
||||
let asset_location_on_penpal_latest: Location = asset_location_on_penpal.try_into().unwrap();
|
||||
let system_asset_location_on_penpal = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let asset_location_on_penpal = PenpalLocalReservableFromAssetHub::get();
|
||||
let system_asset_location_on_penpal = RelayLocation::get();
|
||||
let assets: Assets = vec![
|
||||
(Parent, fee_amount_to_send).into(),
|
||||
(asset_location_on_penpal_latest, asset_amount_to_send).into(),
|
||||
(asset_location_on_penpal.clone(), asset_amount_to_send).into(),
|
||||
]
|
||||
.into();
|
||||
let fee_asset_index = assets
|
||||
@@ -982,9 +981,8 @@ fn reserve_transfer_assets_from_para_to_system_para() {
|
||||
let receiver = AssetHubRococoReceiver::get();
|
||||
let penpal_location_as_seen_by_ahr = AssetHubRococo::sibling_location_of(PenpalA::para_id());
|
||||
let sov_penpal_on_ahr = AssetHubRococo::sovereign_account_id_of(penpal_location_as_seen_by_ahr);
|
||||
let system_para_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let system_para_foreign_asset_location =
|
||||
v3::Location::try_from(PenpalLocalReservableFromAssetHub::get()).unwrap();
|
||||
let system_para_native_asset_location = RelayLocation::get();
|
||||
let system_para_foreign_asset_location = PenpalLocalReservableFromAssetHub::get();
|
||||
let ah_asset_owner = AssetHubRococoAssetOwner::get();
|
||||
let ah_asset_owner_signer = <AssetHubRococo as Chain>::RuntimeOrigin::signed(ah_asset_owner);
|
||||
|
||||
@@ -1019,11 +1017,11 @@ fn reserve_transfer_assets_from_para_to_system_para() {
|
||||
// Query initial balances
|
||||
let sender_system_assets_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_native_asset_location, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_native_asset_location.clone(), &sender)
|
||||
});
|
||||
let sender_foreign_assets_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_foreign_asset_location, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_foreign_asset_location.clone(), &sender)
|
||||
});
|
||||
let receiver_balance_before = test.receiver.balance;
|
||||
let receiver_assets_before = AssetHubRococo::execute_with(|| {
|
||||
@@ -1040,7 +1038,7 @@ fn reserve_transfer_assets_from_para_to_system_para() {
|
||||
// Query final balances
|
||||
let sender_system_assets_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_native_asset_location, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_native_asset_location.clone(), &sender)
|
||||
});
|
||||
let sender_foreign_assets_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
@@ -1079,14 +1077,14 @@ fn reserve_transfer_native_asset_from_para_to_para_through_relay() {
|
||||
let amount_to_send: Balance = ROCOCO_ED * 10000;
|
||||
let asset_owner = PenpalAssetOwner::get();
|
||||
let assets = (Parent, amount_to_send).into();
|
||||
let relay_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let relay_native_asset_location = RelayLocation::get();
|
||||
let sender_as_seen_by_relay = Rococo::child_location_of(PenpalA::para_id());
|
||||
let sov_of_sender_on_relay = Rococo::sovereign_account_id_of(sender_as_seen_by_relay);
|
||||
|
||||
// fund Parachain's sender account
|
||||
PenpalA::mint_foreign_asset(
|
||||
<PenpalA as Chain>::RuntimeOrigin::signed(asset_owner),
|
||||
relay_native_asset_location,
|
||||
relay_native_asset_location.clone(),
|
||||
sender.clone(),
|
||||
amount_to_send * 2,
|
||||
);
|
||||
@@ -1108,11 +1106,11 @@ fn reserve_transfer_native_asset_from_para_to_para_through_relay() {
|
||||
// Query initial balances
|
||||
let sender_assets_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location.clone(), &sender)
|
||||
});
|
||||
let receiver_assets_before = PenpalB::execute_with(|| {
|
||||
type ForeignAssets = <PenpalB as PenpalBPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location, &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location.clone(), &receiver)
|
||||
});
|
||||
|
||||
// Set assertions and dispatchables
|
||||
@@ -1125,7 +1123,7 @@ fn reserve_transfer_native_asset_from_para_to_para_through_relay() {
|
||||
// Query final balances
|
||||
let sender_assets_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location.clone(), &sender)
|
||||
});
|
||||
let receiver_assets_after = PenpalB::execute_with(|| {
|
||||
type ForeignAssets = <PenpalB as PenpalBPallet>::ForeignAssets;
|
||||
|
||||
+12
-9
@@ -17,7 +17,10 @@ use crate::imports::*;
|
||||
|
||||
#[test]
|
||||
fn swap_locally_on_chain_using_local_assets() {
|
||||
let asset_native = Box::new(asset_hub_rococo_runtime::xcm_config::TokenLocationV3::get());
|
||||
let asset_native = Box::new(
|
||||
v3::Location::try_from(asset_hub_rococo_runtime::xcm_config::TokenLocation::get())
|
||||
.expect("conversion works"),
|
||||
);
|
||||
let asset_one = Box::new(v3::Location::new(
|
||||
0,
|
||||
[
|
||||
@@ -227,11 +230,9 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
||||
|
||||
#[test]
|
||||
fn cannot_create_pool_from_pool_assets() {
|
||||
let asset_native = Box::new(asset_hub_rococo_runtime::xcm_config::TokenLocationV3::get());
|
||||
let mut asset_one = asset_hub_rococo_runtime::xcm_config::PoolAssetsPalletLocationV3::get();
|
||||
asset_one
|
||||
.append_with(v3::Junction::GeneralIndex(ASSET_ID.into()))
|
||||
.expect("pool assets");
|
||||
let asset_native = asset_hub_rococo_runtime::xcm_config::TokenLocation::get();
|
||||
let mut asset_one = asset_hub_rococo_runtime::xcm_config::PoolAssetsPalletLocation::get();
|
||||
asset_one.append_with(GeneralIndex(ASSET_ID.into())).expect("pool assets");
|
||||
|
||||
AssetHubRococo::execute_with(|| {
|
||||
let pool_owner_account_id = asset_hub_rococo_runtime::AssetConversionOrigin::get();
|
||||
@@ -254,8 +255,8 @@ fn cannot_create_pool_from_pool_assets() {
|
||||
assert_matches::assert_matches!(
|
||||
<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::create_pool(
|
||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
|
||||
asset_native,
|
||||
Box::new(asset_one),
|
||||
Box::new(v3::Location::try_from(asset_native).expect("conversion works")),
|
||||
Box::new(v3::Location::try_from(asset_one).expect("conversion works")),
|
||||
),
|
||||
Err(DispatchError::Module(ModuleError{index: _, error: _, message})) => assert_eq!(message, Some("Unknown"))
|
||||
);
|
||||
@@ -264,7 +265,9 @@ fn cannot_create_pool_from_pool_assets() {
|
||||
|
||||
#[test]
|
||||
fn pay_xcm_fee_with_some_asset_swapped_for_native() {
|
||||
let asset_native = asset_hub_rococo_runtime::xcm_config::TokenLocationV3::get();
|
||||
let asset_native =
|
||||
v3::Location::try_from(asset_hub_rococo_runtime::xcm_config::TokenLocation::get())
|
||||
.expect("conversion works");
|
||||
let asset_one = xcm::v3::Location {
|
||||
parents: 0,
|
||||
interior: [
|
||||
|
||||
+17
-21
@@ -110,7 +110,7 @@ fn para_dest_assertions(t: RelayToSystemParaTest) {
|
||||
|
||||
fn penpal_to_ah_foreign_assets_sender_assertions(t: ParaToSystemParaTest) {
|
||||
type RuntimeEvent = <PenpalA as Chain>::RuntimeEvent;
|
||||
let system_para_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let system_para_native_asset_location = RelayLocation::get();
|
||||
let expected_asset_id = t.args.asset_id.unwrap();
|
||||
let (_, expected_asset_amount) =
|
||||
non_fee_asset(&t.args.assets, t.args.fee_asset_item as usize).unwrap();
|
||||
@@ -203,7 +203,7 @@ fn ah_to_penpal_foreign_assets_receiver_assertions(t: SystemParaToParaTest) {
|
||||
let (_, expected_asset_amount) =
|
||||
non_fee_asset(&t.args.assets, t.args.fee_asset_item as usize).unwrap();
|
||||
let checking_account = <PenpalA as PenpalAPallet>::PolkadotXcm::check_account();
|
||||
let system_para_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let system_para_native_asset_location = RelayLocation::get();
|
||||
|
||||
PenpalA::assert_xcmp_queue_success(None);
|
||||
|
||||
@@ -420,22 +420,20 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
) {
|
||||
// Init values for Parachain
|
||||
let fee_amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 10000;
|
||||
let asset_location_on_penpal =
|
||||
v3::Location::try_from(PenpalLocalTeleportableToAssetHub::get()).unwrap();
|
||||
let asset_location_on_penpal = PenpalLocalTeleportableToAssetHub::get();
|
||||
let asset_id_on_penpal = match asset_location_on_penpal.last() {
|
||||
Some(v3::Junction::GeneralIndex(id)) => *id as u32,
|
||||
Some(Junction::GeneralIndex(id)) => *id as u32,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let asset_amount_to_send = ASSET_HUB_ROCOCO_ED * 1000;
|
||||
let asset_owner = PenpalAssetOwner::get();
|
||||
let system_para_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let system_para_native_asset_location = RelayLocation::get();
|
||||
let sender = PenpalASender::get();
|
||||
let penpal_check_account = <PenpalA as PenpalAPallet>::PolkadotXcm::check_account();
|
||||
let ah_as_seen_by_penpal = PenpalA::sibling_location_of(AssetHubRococo::para_id());
|
||||
let asset_location_on_penpal_latest: Location = asset_location_on_penpal.try_into().unwrap();
|
||||
let penpal_assets: Assets = vec![
|
||||
(Parent, fee_amount_to_send).into(),
|
||||
(asset_location_on_penpal_latest, asset_amount_to_send).into(),
|
||||
(asset_location_on_penpal.clone(), asset_amount_to_send).into(),
|
||||
]
|
||||
.into();
|
||||
let fee_asset_index = penpal_assets
|
||||
@@ -447,7 +445,7 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
// fund Parachain's sender account
|
||||
PenpalA::mint_foreign_asset(
|
||||
<PenpalA as Chain>::RuntimeOrigin::signed(asset_owner.clone()),
|
||||
system_para_native_asset_location,
|
||||
system_para_native_asset_location.clone(),
|
||||
sender.clone(),
|
||||
fee_amount_to_send * 2,
|
||||
);
|
||||
@@ -471,7 +469,7 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
|
||||
// Init values for System Parachain
|
||||
let foreign_asset_at_asset_hub_rococo =
|
||||
v3::Location::new(1, [v3::Junction::Parachain(PenpalA::para_id().into())])
|
||||
Location::new(1, [Junction::Parachain(PenpalA::para_id().into())])
|
||||
.appended_with(asset_location_on_penpal)
|
||||
.unwrap();
|
||||
let penpal_to_ah_beneficiary_id = AssetHubRococoReceiver::get();
|
||||
@@ -493,7 +491,7 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
let penpal_sender_balance_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
system_para_native_asset_location,
|
||||
system_para_native_asset_location.clone(),
|
||||
&PenpalASender::get(),
|
||||
)
|
||||
});
|
||||
@@ -507,7 +505,7 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
let ah_receiver_assets_before = AssetHubRococo::execute_with(|| {
|
||||
type Assets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
|
||||
<Assets as Inspect<_>>::balance(
|
||||
foreign_asset_at_asset_hub_rococo,
|
||||
foreign_asset_at_asset_hub_rococo.clone().try_into().unwrap(),
|
||||
&AssetHubRococoReceiver::get(),
|
||||
)
|
||||
});
|
||||
@@ -520,7 +518,7 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
let penpal_sender_balance_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
system_para_native_asset_location,
|
||||
system_para_native_asset_location.clone(),
|
||||
&PenpalASender::get(),
|
||||
)
|
||||
});
|
||||
@@ -534,7 +532,7 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
let ah_receiver_assets_after = AssetHubRococo::execute_with(|| {
|
||||
type Assets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
|
||||
<Assets as Inspect<_>>::balance(
|
||||
foreign_asset_at_asset_hub_rococo,
|
||||
foreign_asset_at_asset_hub_rococo.clone().try_into().unwrap(),
|
||||
&AssetHubRococoReceiver::get(),
|
||||
)
|
||||
});
|
||||
@@ -562,19 +560,17 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
type ForeignAssets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
|
||||
assert_ok!(ForeignAssets::transfer(
|
||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoReceiver::get()),
|
||||
foreign_asset_at_asset_hub_rococo,
|
||||
foreign_asset_at_asset_hub_rococo.clone().try_into().unwrap(),
|
||||
AssetHubRococoSender::get().into(),
|
||||
asset_amount_to_send,
|
||||
));
|
||||
});
|
||||
|
||||
let foreign_asset_at_asset_hub_rococo_latest: Location =
|
||||
foreign_asset_at_asset_hub_rococo.try_into().unwrap();
|
||||
let ah_to_penpal_beneficiary_id = PenpalAReceiver::get();
|
||||
let penpal_as_seen_by_ah = AssetHubRococo::sibling_location_of(PenpalA::para_id());
|
||||
let ah_assets: Assets = vec![
|
||||
(Parent, fee_amount_to_send).into(),
|
||||
(foreign_asset_at_asset_hub_rococo_latest, asset_amount_to_send).into(),
|
||||
(foreign_asset_at_asset_hub_rococo.clone(), asset_amount_to_send).into(),
|
||||
]
|
||||
.into();
|
||||
let fee_asset_index = ah_assets
|
||||
@@ -602,7 +598,7 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
let penpal_receiver_balance_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
system_para_native_asset_location,
|
||||
system_para_native_asset_location.clone(),
|
||||
&PenpalAReceiver::get(),
|
||||
)
|
||||
});
|
||||
@@ -610,7 +606,7 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
let ah_sender_assets_before = AssetHubRococo::execute_with(|| {
|
||||
type ForeignAssets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
foreign_asset_at_asset_hub_rococo,
|
||||
foreign_asset_at_asset_hub_rococo.clone().try_into().unwrap(),
|
||||
&AssetHubRococoSender::get(),
|
||||
)
|
||||
});
|
||||
@@ -636,7 +632,7 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
let ah_sender_assets_after = AssetHubRococo::execute_with(|| {
|
||||
type ForeignAssets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
foreign_asset_at_asset_hub_rococo,
|
||||
foreign_asset_at_asset_hub_rococo.try_into().unwrap(),
|
||||
&AssetHubRococoSender::get(),
|
||||
)
|
||||
});
|
||||
|
||||
+68
-48
@@ -137,14 +137,13 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
|
||||
let destination = AssetHubWestend::sibling_location_of(PenpalA::para_id());
|
||||
let sender = AssetHubWestendSender::get();
|
||||
let native_amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000;
|
||||
let native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let native_asset_location = RelayLocation::get();
|
||||
let receiver = PenpalAReceiver::get();
|
||||
let assets_owner = PenpalAssetOwner::get();
|
||||
// Foreign asset used: bridged ROC
|
||||
let foreign_amount_to_send = ASSET_HUB_WESTEND_ED * 10_000_000;
|
||||
let roc_at_westend_parachains =
|
||||
v3::Location::new(2, [v3::Junction::GlobalConsensus(v3::NetworkId::Rococo)]);
|
||||
let roc_at_westend_parachains_latest: Location = roc_at_westend_parachains.try_into().unwrap();
|
||||
Location::new(2, [Junction::GlobalConsensus(NetworkId::Rococo)]);
|
||||
|
||||
// Configure destination chain to trust AH as reserve of ROC
|
||||
PenpalA::execute_with(|| {
|
||||
@@ -157,14 +156,14 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
|
||||
));
|
||||
});
|
||||
PenpalA::force_create_foreign_asset(
|
||||
roc_at_westend_parachains,
|
||||
roc_at_westend_parachains.clone(),
|
||||
assets_owner.clone(),
|
||||
false,
|
||||
ASSET_MIN_BALANCE,
|
||||
vec![],
|
||||
);
|
||||
AssetHubWestend::force_create_foreign_asset(
|
||||
roc_at_westend_parachains,
|
||||
roc_at_westend_parachains.clone().try_into().unwrap(),
|
||||
assets_owner.clone(),
|
||||
false,
|
||||
ASSET_MIN_BALANCE,
|
||||
@@ -172,7 +171,7 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
|
||||
);
|
||||
AssetHubWestend::mint_foreign_asset(
|
||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(assets_owner),
|
||||
roc_at_westend_parachains,
|
||||
roc_at_westend_parachains.clone().try_into().unwrap(),
|
||||
sender.clone(),
|
||||
foreign_amount_to_send * 2,
|
||||
);
|
||||
@@ -180,7 +179,7 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
|
||||
// Assets to send
|
||||
let assets: Vec<Asset> = vec![
|
||||
(Parent, native_amount_to_send).into(),
|
||||
(roc_at_westend_parachains_latest, foreign_amount_to_send).into(),
|
||||
(roc_at_westend_parachains.clone(), foreign_amount_to_send).into(),
|
||||
];
|
||||
let fee_asset_id = AssetId(Parent.into());
|
||||
let fee_asset_item = assets.iter().position(|a| a.id == fee_asset_id).unwrap() as u32;
|
||||
@@ -204,15 +203,18 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
|
||||
let sender_balance_before = test.sender.balance;
|
||||
let sender_rocs_before = AssetHubWestend::execute_with(|| {
|
||||
type ForeignAssets = <AssetHubWestend as AssetHubWestendPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_at_westend_parachains, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
roc_at_westend_parachains.clone().try_into().unwrap(),
|
||||
&sender,
|
||||
)
|
||||
});
|
||||
let receiver_assets_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(native_asset_location.into(), &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(native_asset_location.clone(), &receiver)
|
||||
});
|
||||
let receiver_rocs_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_at_westend_parachains, &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_at_westend_parachains.clone(), &receiver)
|
||||
});
|
||||
|
||||
// Set assertions and dispatchables
|
||||
@@ -225,7 +227,10 @@ fn transfer_foreign_assets_from_asset_hub_to_para() {
|
||||
let sender_balance_after = test.sender.balance;
|
||||
let sender_rocs_after = AssetHubWestend::execute_with(|| {
|
||||
type ForeignAssets = <AssetHubWestend as AssetHubWestendPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_at_westend_parachains, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
roc_at_westend_parachains.clone().try_into().unwrap(),
|
||||
&sender,
|
||||
)
|
||||
});
|
||||
let receiver_assets_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
@@ -262,14 +267,13 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
|
||||
let destination = PenpalA::sibling_location_of(AssetHubWestend::para_id());
|
||||
let sender = PenpalASender::get();
|
||||
let native_amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 10000;
|
||||
let native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let native_asset_location = RelayLocation::get();
|
||||
let assets_owner = PenpalAssetOwner::get();
|
||||
|
||||
// Foreign asset used: bridged ROC
|
||||
let foreign_amount_to_send = ASSET_HUB_WESTEND_ED * 10_000_000;
|
||||
let roc_at_westend_parachains =
|
||||
v3::Location::new(2, [v3::Junction::GlobalConsensus(v3::NetworkId::Rococo)]);
|
||||
let roc_at_westend_parachains_latest: Location = roc_at_westend_parachains.try_into().unwrap();
|
||||
Location::new(2, [Junction::GlobalConsensus(NetworkId::Rococo)]);
|
||||
|
||||
// Configure destination chain to trust AH as reserve of ROC
|
||||
PenpalA::execute_with(|| {
|
||||
@@ -282,14 +286,14 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
|
||||
));
|
||||
});
|
||||
PenpalA::force_create_foreign_asset(
|
||||
roc_at_westend_parachains,
|
||||
roc_at_westend_parachains.clone(),
|
||||
assets_owner.clone(),
|
||||
false,
|
||||
ASSET_MIN_BALANCE,
|
||||
vec![],
|
||||
);
|
||||
AssetHubWestend::force_create_foreign_asset(
|
||||
roc_at_westend_parachains,
|
||||
roc_at_westend_parachains.clone().try_into().unwrap(),
|
||||
assets_owner.clone(),
|
||||
false,
|
||||
ASSET_MIN_BALANCE,
|
||||
@@ -299,13 +303,13 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
|
||||
// fund Parachain's sender account
|
||||
PenpalA::mint_foreign_asset(
|
||||
<PenpalA as Chain>::RuntimeOrigin::signed(assets_owner.clone()),
|
||||
native_asset_location,
|
||||
native_asset_location.clone(),
|
||||
sender.clone(),
|
||||
native_amount_to_send * 2,
|
||||
);
|
||||
PenpalA::mint_foreign_asset(
|
||||
<PenpalA as Chain>::RuntimeOrigin::signed(assets_owner.clone()),
|
||||
roc_at_westend_parachains,
|
||||
roc_at_westend_parachains.clone(),
|
||||
sender.clone(),
|
||||
foreign_amount_to_send * 2,
|
||||
);
|
||||
@@ -323,7 +327,7 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
|
||||
)]);
|
||||
AssetHubWestend::mint_foreign_asset(
|
||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(assets_owner),
|
||||
roc_at_westend_parachains,
|
||||
roc_at_westend_parachains.clone().try_into().unwrap(),
|
||||
sov_penpal_on_ahr,
|
||||
foreign_amount_to_send * 2,
|
||||
);
|
||||
@@ -331,7 +335,7 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
|
||||
// Assets to send
|
||||
let assets: Vec<Asset> = vec![
|
||||
(Parent, native_amount_to_send).into(),
|
||||
(roc_at_westend_parachains_latest, foreign_amount_to_send).into(),
|
||||
(roc_at_westend_parachains.clone(), foreign_amount_to_send).into(),
|
||||
];
|
||||
let fee_asset_id = AssetId(Parent.into());
|
||||
let fee_asset_item = assets.iter().position(|a| a.id == fee_asset_id).unwrap() as u32;
|
||||
@@ -354,16 +358,19 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
|
||||
// Query initial balances
|
||||
let sender_native_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(native_asset_location, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(native_asset_location.clone(), &sender)
|
||||
});
|
||||
let sender_rocs_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_at_westend_parachains, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_at_westend_parachains.clone(), &sender)
|
||||
});
|
||||
let receiver_native_before = test.receiver.balance;
|
||||
let receiver_rocs_before = AssetHubWestend::execute_with(|| {
|
||||
type ForeignAssets = <AssetHubWestend as AssetHubWestendPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_at_westend_parachains, &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
roc_at_westend_parachains.clone().try_into().unwrap(),
|
||||
&receiver,
|
||||
)
|
||||
});
|
||||
|
||||
// Set assertions and dispatchables
|
||||
@@ -379,12 +386,15 @@ fn transfer_foreign_assets_from_para_to_asset_hub() {
|
||||
});
|
||||
let sender_rocs_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_at_westend_parachains, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_at_westend_parachains.clone(), &sender)
|
||||
});
|
||||
let receiver_native_after = test.receiver.balance;
|
||||
let receiver_rocs_after = AssetHubWestend::execute_with(|| {
|
||||
type ForeignAssets = <AssetHubWestend as AssetHubWestendPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_at_westend_parachains, &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
roc_at_westend_parachains.try_into().unwrap(),
|
||||
&receiver,
|
||||
)
|
||||
});
|
||||
|
||||
// Sender's balance is reduced by amount sent plus delivery fees
|
||||
@@ -413,8 +423,7 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
|
||||
let sender = PenpalASender::get();
|
||||
let wnd_to_send: Balance = WESTEND_ED * 10000;
|
||||
let assets_owner = PenpalAssetOwner::get();
|
||||
let wnd_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let wnd_location_latest: Location = wnd_location.try_into().unwrap();
|
||||
let wnd_location = RelayLocation::get();
|
||||
let sender_as_seen_by_ah = AssetHubWestend::sibling_location_of(PenpalA::para_id());
|
||||
let sov_of_sender_on_ah = AssetHubWestend::sovereign_account_id_of(sender_as_seen_by_ah);
|
||||
let receiver_as_seen_by_ah = AssetHubWestend::sibling_location_of(PenpalB::para_id());
|
||||
@@ -434,24 +443,23 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
|
||||
|
||||
// Register ROC as foreign asset and transfer it around the Westend ecosystem
|
||||
let roc_at_westend_parachains =
|
||||
v3::Location::new(2, [v3::Junction::GlobalConsensus(v3::NetworkId::Rococo)]);
|
||||
let roc_at_westend_parachains_latest: Location = roc_at_westend_parachains.try_into().unwrap();
|
||||
Location::new(2, [Junction::GlobalConsensus(NetworkId::Rococo)]);
|
||||
AssetHubWestend::force_create_foreign_asset(
|
||||
roc_at_westend_parachains,
|
||||
roc_at_westend_parachains.clone().try_into().unwrap(),
|
||||
assets_owner.clone(),
|
||||
false,
|
||||
ASSET_MIN_BALANCE,
|
||||
vec![],
|
||||
);
|
||||
PenpalA::force_create_foreign_asset(
|
||||
roc_at_westend_parachains,
|
||||
roc_at_westend_parachains.clone(),
|
||||
assets_owner.clone(),
|
||||
false,
|
||||
ASSET_MIN_BALANCE,
|
||||
vec![],
|
||||
);
|
||||
PenpalB::force_create_foreign_asset(
|
||||
roc_at_westend_parachains,
|
||||
roc_at_westend_parachains.clone(),
|
||||
assets_owner.clone(),
|
||||
false,
|
||||
ASSET_MIN_BALANCE,
|
||||
@@ -461,13 +469,13 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
|
||||
// fund Parachain's sender account
|
||||
PenpalA::mint_foreign_asset(
|
||||
<PenpalA as Chain>::RuntimeOrigin::signed(assets_owner.clone()),
|
||||
wnd_location,
|
||||
wnd_location.clone(),
|
||||
sender.clone(),
|
||||
wnd_to_send * 2,
|
||||
);
|
||||
PenpalA::mint_foreign_asset(
|
||||
<PenpalA as Chain>::RuntimeOrigin::signed(assets_owner.clone()),
|
||||
roc_at_westend_parachains,
|
||||
roc_at_westend_parachains.clone(),
|
||||
sender.clone(),
|
||||
roc_to_send * 2,
|
||||
);
|
||||
@@ -475,7 +483,7 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
|
||||
AssetHubWestend::fund_accounts(vec![(sov_of_sender_on_ah.clone().into(), wnd_to_send * 2)]);
|
||||
AssetHubWestend::mint_foreign_asset(
|
||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(assets_owner),
|
||||
roc_at_westend_parachains,
|
||||
roc_at_westend_parachains.clone().try_into().unwrap(),
|
||||
sov_of_sender_on_ah.clone(),
|
||||
roc_to_send * 2,
|
||||
);
|
||||
@@ -485,10 +493,10 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
|
||||
|
||||
// Assets to send
|
||||
let assets: Vec<Asset> = vec![
|
||||
(wnd_location_latest.clone(), wnd_to_send).into(),
|
||||
(roc_at_westend_parachains_latest, roc_to_send).into(),
|
||||
(wnd_location.clone(), wnd_to_send).into(),
|
||||
(roc_at_westend_parachains.clone(), roc_to_send).into(),
|
||||
];
|
||||
let fee_asset_id: AssetId = wnd_location_latest.into();
|
||||
let fee_asset_id: AssetId = wnd_location.clone().into();
|
||||
let fee_asset_item = assets.iter().position(|a| a.id == fee_asset_id).unwrap() as u32;
|
||||
|
||||
// Init Test
|
||||
@@ -509,31 +517,37 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
|
||||
// Query initial balances
|
||||
let sender_wnds_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_location, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_location.clone(), &sender)
|
||||
});
|
||||
let sender_rocs_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_at_westend_parachains, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_at_westend_parachains.clone(), &sender)
|
||||
});
|
||||
let wnds_in_sender_reserve_on_ah_before =
|
||||
<AssetHubWestend as Chain>::account_data_of(sov_of_sender_on_ah.clone()).free;
|
||||
let rocs_in_sender_reserve_on_ah_before = AssetHubWestend::execute_with(|| {
|
||||
type Assets = <AssetHubWestend as AssetHubWestendPallet>::ForeignAssets;
|
||||
<Assets as Inspect<_>>::balance(roc_at_westend_parachains, &sov_of_sender_on_ah)
|
||||
<Assets as Inspect<_>>::balance(
|
||||
roc_at_westend_parachains.clone().try_into().unwrap(),
|
||||
&sov_of_sender_on_ah,
|
||||
)
|
||||
});
|
||||
let wnds_in_receiver_reserve_on_ah_before =
|
||||
<AssetHubWestend as Chain>::account_data_of(sov_of_receiver_on_ah.clone()).free;
|
||||
let rocs_in_receiver_reserve_on_ah_before = AssetHubWestend::execute_with(|| {
|
||||
type Assets = <AssetHubWestend as AssetHubWestendPallet>::ForeignAssets;
|
||||
<Assets as Inspect<_>>::balance(roc_at_westend_parachains, &sov_of_receiver_on_ah)
|
||||
<Assets as Inspect<_>>::balance(
|
||||
roc_at_westend_parachains.clone().try_into().unwrap(),
|
||||
&sov_of_receiver_on_ah,
|
||||
)
|
||||
});
|
||||
let receiver_wnds_before = PenpalB::execute_with(|| {
|
||||
type ForeignAssets = <PenpalB as PenpalBPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_location, &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_location.clone(), &receiver)
|
||||
});
|
||||
let receiver_rocs_before = PenpalB::execute_with(|| {
|
||||
type ForeignAssets = <PenpalB as PenpalBPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_at_westend_parachains, &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_at_westend_parachains.clone(), &receiver)
|
||||
});
|
||||
|
||||
// Set assertions and dispatchables
|
||||
@@ -546,21 +560,27 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
|
||||
// Query final balances
|
||||
let sender_wnds_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_location, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_location.clone(), &sender)
|
||||
});
|
||||
let sender_rocs_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_at_westend_parachains, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_at_westend_parachains.clone(), &sender)
|
||||
});
|
||||
let rocs_in_sender_reserve_on_ah_after = AssetHubWestend::execute_with(|| {
|
||||
type Assets = <AssetHubWestend as AssetHubWestendPallet>::ForeignAssets;
|
||||
<Assets as Inspect<_>>::balance(roc_at_westend_parachains, &sov_of_sender_on_ah)
|
||||
<Assets as Inspect<_>>::balance(
|
||||
roc_at_westend_parachains.clone().try_into().unwrap(),
|
||||
&sov_of_sender_on_ah,
|
||||
)
|
||||
});
|
||||
let wnds_in_sender_reserve_on_ah_after =
|
||||
<AssetHubWestend as Chain>::account_data_of(sov_of_sender_on_ah).free;
|
||||
let rocs_in_receiver_reserve_on_ah_after = AssetHubWestend::execute_with(|| {
|
||||
type Assets = <AssetHubWestend as AssetHubWestendPallet>::ForeignAssets;
|
||||
<Assets as Inspect<_>>::balance(roc_at_westend_parachains, &sov_of_receiver_on_ah)
|
||||
<Assets as Inspect<_>>::balance(
|
||||
roc_at_westend_parachains.clone().try_into().unwrap(),
|
||||
&sov_of_receiver_on_ah,
|
||||
)
|
||||
});
|
||||
let wnds_in_receiver_reserve_on_ah_after =
|
||||
<AssetHubWestend as Chain>::account_data_of(sov_of_receiver_on_ah).free;
|
||||
|
||||
+39
-41
@@ -47,7 +47,7 @@ fn para_to_relay_sender_assertions(t: ParaToRelayTest) {
|
||||
RuntimeEvent::ForeignAssets(
|
||||
pallet_assets::Event::Burned { asset_id, owner, balance, .. }
|
||||
) => {
|
||||
asset_id: *asset_id == v3::Location::try_from(RelayLocation::get()).unwrap(),
|
||||
asset_id: *asset_id == RelayLocation::get(),
|
||||
owner: *owner == t.sender.account_id,
|
||||
balance: *balance == t.args.amount,
|
||||
},
|
||||
@@ -106,6 +106,7 @@ pub fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) {
|
||||
|
||||
pub fn system_para_to_para_receiver_assertions(t: SystemParaToParaTest) {
|
||||
type RuntimeEvent = <PenpalA as Chain>::RuntimeEvent;
|
||||
|
||||
PenpalA::assert_xcmp_queue_success(None);
|
||||
for asset in t.args.assets.into_inner().into_iter() {
|
||||
let expected_id = asset.id.0.try_into().unwrap();
|
||||
@@ -125,7 +126,7 @@ pub fn para_to_system_para_sender_assertions(t: ParaToSystemParaTest) {
|
||||
type RuntimeEvent = <PenpalA as Chain>::RuntimeEvent;
|
||||
PenpalA::assert_xcm_pallet_attempted_complete(None);
|
||||
for asset in t.args.assets.into_inner().into_iter() {
|
||||
let expected_id = asset.id.0.try_into().unwrap();
|
||||
let expected_id = asset.id.0;
|
||||
let asset_amount = if let Fungible(a) = asset.fun { Some(a) } else { None }.unwrap();
|
||||
assert_expected_events!(
|
||||
PenpalA,
|
||||
@@ -265,9 +266,8 @@ fn system_para_to_para_assets_sender_assertions(t: SystemParaToParaTest) {
|
||||
|
||||
fn para_to_system_para_assets_sender_assertions(t: ParaToSystemParaTest) {
|
||||
type RuntimeEvent = <PenpalA as Chain>::RuntimeEvent;
|
||||
let system_para_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let reservable_asset_location =
|
||||
v3::Location::try_from(PenpalLocalReservableFromAssetHub::get()).unwrap();
|
||||
let system_para_native_asset_location = RelayLocation::get();
|
||||
let reservable_asset_location = PenpalLocalReservableFromAssetHub::get();
|
||||
PenpalA::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(864_610_000, 8799)));
|
||||
assert_expected_events!(
|
||||
PenpalA,
|
||||
@@ -297,14 +297,13 @@ fn para_to_system_para_assets_sender_assertions(t: ParaToSystemParaTest) {
|
||||
|
||||
fn system_para_to_para_assets_receiver_assertions(t: SystemParaToParaTest) {
|
||||
type RuntimeEvent = <PenpalA as Chain>::RuntimeEvent;
|
||||
let system_para_asset_location =
|
||||
v3::Location::try_from(PenpalLocalReservableFromAssetHub::get()).unwrap();
|
||||
let system_para_asset_location = PenpalLocalReservableFromAssetHub::get();
|
||||
PenpalA::assert_xcmp_queue_success(None);
|
||||
assert_expected_events!(
|
||||
PenpalA,
|
||||
vec![
|
||||
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, .. }) => {
|
||||
asset_id: *asset_id == v3::Location::try_from(RelayLocation::get()).unwrap(),
|
||||
asset_id: *asset_id == RelayLocation::get(),
|
||||
owner: *owner == t.receiver.account_id,
|
||||
},
|
||||
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, amount }) => {
|
||||
@@ -356,7 +355,7 @@ fn relay_to_para_assets_receiver_assertions(t: RelayToParaTest) {
|
||||
PenpalA,
|
||||
vec![
|
||||
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, .. }) => {
|
||||
asset_id: *asset_id == v3::Location::try_from(RelayLocation::get()).unwrap(),
|
||||
asset_id: *asset_id == RelayLocation::get(),
|
||||
owner: *owner == t.receiver.account_id,
|
||||
},
|
||||
RuntimeEvent::MessageQueue(
|
||||
@@ -576,7 +575,7 @@ fn reserve_transfer_native_asset_from_relay_to_para() {
|
||||
let amount_to_send: Balance = WESTEND_ED * 1000;
|
||||
|
||||
// Init values fot Parachain
|
||||
let relay_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let relay_native_asset_location = RelayLocation::get();
|
||||
let receiver = PenpalAReceiver::get();
|
||||
|
||||
// Init Test
|
||||
@@ -591,7 +590,7 @@ fn reserve_transfer_native_asset_from_relay_to_para() {
|
||||
let sender_balance_before = test.sender.balance;
|
||||
let receiver_assets_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location.into(), &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location.clone(), &receiver)
|
||||
});
|
||||
|
||||
// Set assertions and dispatchables
|
||||
@@ -604,7 +603,7 @@ fn reserve_transfer_native_asset_from_relay_to_para() {
|
||||
let sender_balance_after = test.sender.balance;
|
||||
let receiver_assets_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location.into(), &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location, &receiver)
|
||||
});
|
||||
|
||||
// Sender's balance is reduced by amount sent plus delivery fees
|
||||
@@ -626,12 +625,12 @@ fn reserve_transfer_native_asset_from_para_to_relay() {
|
||||
let amount_to_send: Balance = WESTEND_ED * 1000;
|
||||
let assets: Assets = (Parent, amount_to_send).into();
|
||||
let asset_owner = PenpalAssetOwner::get();
|
||||
let relay_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let relay_native_asset_location = RelayLocation::get();
|
||||
|
||||
// fund Parachain's sender account
|
||||
PenpalA::mint_foreign_asset(
|
||||
<PenpalA as Chain>::RuntimeOrigin::signed(asset_owner),
|
||||
relay_native_asset_location,
|
||||
relay_native_asset_location.clone(),
|
||||
sender.clone(),
|
||||
amount_to_send * 2,
|
||||
);
|
||||
@@ -662,7 +661,7 @@ fn reserve_transfer_native_asset_from_para_to_relay() {
|
||||
// Query initial balances
|
||||
let sender_assets_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location.into(), &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location.clone(), &sender)
|
||||
});
|
||||
let receiver_balance_before = test.receiver.balance;
|
||||
|
||||
@@ -675,7 +674,7 @@ fn reserve_transfer_native_asset_from_para_to_relay() {
|
||||
// Query final balances
|
||||
let sender_assets_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location.into(), &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location, &sender)
|
||||
});
|
||||
let receiver_balance_after = test.receiver.balance;
|
||||
|
||||
@@ -702,7 +701,7 @@ fn reserve_transfer_native_asset_from_system_para_to_para() {
|
||||
let assets: Assets = (Parent, amount_to_send).into();
|
||||
|
||||
// Init values for Parachain
|
||||
let system_para_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let system_para_native_asset_location = RelayLocation::get();
|
||||
let receiver = PenpalAReceiver::get();
|
||||
|
||||
// Init Test
|
||||
@@ -724,7 +723,7 @@ fn reserve_transfer_native_asset_from_system_para_to_para() {
|
||||
let sender_balance_before = test.sender.balance;
|
||||
let receiver_assets_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_native_asset_location.into(), &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_native_asset_location.clone(), &receiver)
|
||||
});
|
||||
|
||||
// Set assertions and dispatchables
|
||||
@@ -758,13 +757,13 @@ fn reserve_transfer_native_asset_from_para_to_system_para() {
|
||||
let sender = PenpalASender::get();
|
||||
let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000;
|
||||
let assets: Assets = (Parent, amount_to_send).into();
|
||||
let system_para_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let system_para_native_asset_location = RelayLocation::get();
|
||||
let asset_owner = PenpalAssetOwner::get();
|
||||
|
||||
// fund Parachain's sender account
|
||||
PenpalA::mint_foreign_asset(
|
||||
<PenpalA as Chain>::RuntimeOrigin::signed(asset_owner),
|
||||
system_para_native_asset_location,
|
||||
system_para_native_asset_location.clone(),
|
||||
sender.clone(),
|
||||
amount_to_send * 2,
|
||||
);
|
||||
@@ -796,7 +795,7 @@ fn reserve_transfer_native_asset_from_para_to_system_para() {
|
||||
// Query initial balances
|
||||
let sender_assets_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_native_asset_location, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_native_asset_location.clone(), &sender)
|
||||
});
|
||||
let receiver_balance_before = test.receiver.balance;
|
||||
|
||||
@@ -864,9 +863,8 @@ fn reserve_transfer_assets_from_system_para_to_para() {
|
||||
|
||||
// Init values for Parachain
|
||||
let receiver = PenpalAReceiver::get();
|
||||
let system_para_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let system_para_foreign_asset_location =
|
||||
v3::Location::try_from(PenpalLocalReservableFromAssetHub::get()).unwrap();
|
||||
let system_para_native_asset_location = RelayLocation::get();
|
||||
let system_para_foreign_asset_location = PenpalLocalReservableFromAssetHub::get();
|
||||
|
||||
// Init Test
|
||||
let para_test_args = TestContext {
|
||||
@@ -891,11 +889,14 @@ fn reserve_transfer_assets_from_system_para_to_para() {
|
||||
});
|
||||
let receiver_system_native_assets_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_native_asset_location, &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_native_asset_location.clone(), &receiver)
|
||||
});
|
||||
let receiver_foreign_assets_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_foreign_asset_location, &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
system_para_foreign_asset_location.clone(),
|
||||
&receiver,
|
||||
)
|
||||
});
|
||||
|
||||
// Set assertions and dispatchables
|
||||
@@ -950,13 +951,11 @@ fn reserve_transfer_assets_from_para_to_system_para() {
|
||||
let asset_amount_to_send = ASSET_HUB_WESTEND_ED * 100;
|
||||
let penpal_asset_owner = PenpalAssetOwner::get();
|
||||
let penpal_asset_owner_signer = <PenpalA as Chain>::RuntimeOrigin::signed(penpal_asset_owner);
|
||||
let asset_location_on_penpal =
|
||||
v3::Location::try_from(PenpalLocalReservableFromAssetHub::get()).unwrap();
|
||||
let asset_location_on_penpal_latest: Location = asset_location_on_penpal.try_into().unwrap();
|
||||
let system_asset_location_on_penpal = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let asset_location_on_penpal = PenpalLocalReservableFromAssetHub::get();
|
||||
let system_asset_location_on_penpal = RelayLocation::get();
|
||||
let assets: Assets = vec![
|
||||
(Parent, fee_amount_to_send).into(),
|
||||
(asset_location_on_penpal_latest, asset_amount_to_send).into(),
|
||||
(asset_location_on_penpal.clone(), asset_amount_to_send).into(),
|
||||
]
|
||||
.into();
|
||||
let fee_asset_index = assets
|
||||
@@ -984,9 +983,8 @@ fn reserve_transfer_assets_from_para_to_system_para() {
|
||||
let penpal_location_as_seen_by_ahr = AssetHubWestend::sibling_location_of(PenpalA::para_id());
|
||||
let sov_penpal_on_ahr =
|
||||
AssetHubWestend::sovereign_account_id_of(penpal_location_as_seen_by_ahr);
|
||||
let system_para_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let system_para_foreign_asset_location =
|
||||
v3::Location::try_from(PenpalLocalReservableFromAssetHub::get()).unwrap();
|
||||
let system_para_native_asset_location = RelayLocation::get();
|
||||
let system_para_foreign_asset_location = PenpalLocalReservableFromAssetHub::get();
|
||||
let ah_asset_owner = AssetHubWestendAssetOwner::get();
|
||||
let ah_asset_owner_signer = <AssetHubWestend as Chain>::RuntimeOrigin::signed(ah_asset_owner);
|
||||
|
||||
@@ -1021,11 +1019,11 @@ fn reserve_transfer_assets_from_para_to_system_para() {
|
||||
// Query initial balances
|
||||
let sender_system_assets_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_native_asset_location, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_native_asset_location.clone(), &sender)
|
||||
});
|
||||
let sender_foreign_assets_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_foreign_asset_location, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(system_para_foreign_asset_location.clone(), &sender)
|
||||
});
|
||||
let receiver_balance_before = test.receiver.balance;
|
||||
let receiver_assets_before = AssetHubWestend::execute_with(|| {
|
||||
@@ -1081,14 +1079,14 @@ fn reserve_transfer_native_asset_from_para_to_para_through_relay() {
|
||||
let amount_to_send: Balance = WESTEND_ED * 10000;
|
||||
let asset_owner = PenpalAssetOwner::get();
|
||||
let assets = (Parent, amount_to_send).into();
|
||||
let relay_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let relay_native_asset_location = RelayLocation::get();
|
||||
let sender_as_seen_by_relay = Westend::child_location_of(PenpalA::para_id());
|
||||
let sov_of_sender_on_relay = Westend::sovereign_account_id_of(sender_as_seen_by_relay);
|
||||
|
||||
// fund Parachain's sender account
|
||||
PenpalA::mint_foreign_asset(
|
||||
<PenpalA as Chain>::RuntimeOrigin::signed(asset_owner),
|
||||
relay_native_asset_location,
|
||||
relay_native_asset_location.clone(),
|
||||
sender.clone(),
|
||||
amount_to_send * 2,
|
||||
);
|
||||
@@ -1110,11 +1108,11 @@ fn reserve_transfer_native_asset_from_para_to_para_through_relay() {
|
||||
// Query initial balances
|
||||
let sender_assets_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location.clone(), &sender)
|
||||
});
|
||||
let receiver_assets_before = PenpalB::execute_with(|| {
|
||||
type ForeignAssets = <PenpalB as PenpalBPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location, &receiver)
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location.clone(), &receiver)
|
||||
});
|
||||
|
||||
// Set assertions and dispatchables
|
||||
@@ -1127,7 +1125,7 @@ fn reserve_transfer_native_asset_from_para_to_para_through_relay() {
|
||||
// Query final balances
|
||||
let sender_assets_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location, &sender)
|
||||
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location.clone(), &sender)
|
||||
});
|
||||
let receiver_assets_after = PenpalB::execute_with(|| {
|
||||
type ForeignAssets = <PenpalB as PenpalBPallet>::ForeignAssets;
|
||||
|
||||
+12
-9
@@ -17,7 +17,10 @@ use crate::imports::*;
|
||||
|
||||
#[test]
|
||||
fn swap_locally_on_chain_using_local_assets() {
|
||||
let asset_native = Box::new(asset_hub_westend_runtime::xcm_config::WestendLocationV3::get());
|
||||
let asset_native = Box::new(
|
||||
v3::Location::try_from(asset_hub_westend_runtime::xcm_config::WestendLocation::get())
|
||||
.expect("conversion works"),
|
||||
);
|
||||
let asset_one = Box::new(v3::Location {
|
||||
parents: 0,
|
||||
interior: [
|
||||
@@ -226,11 +229,9 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
||||
|
||||
#[test]
|
||||
fn cannot_create_pool_from_pool_assets() {
|
||||
let asset_native = Box::new(asset_hub_westend_runtime::xcm_config::WestendLocationV3::get());
|
||||
let mut asset_one = asset_hub_westend_runtime::xcm_config::PoolAssetsPalletLocationV3::get();
|
||||
asset_one
|
||||
.append_with(v3::Junction::GeneralIndex(ASSET_ID.into()))
|
||||
.expect("pool assets");
|
||||
let asset_native = asset_hub_westend_runtime::xcm_config::WestendLocation::get();
|
||||
let mut asset_one = asset_hub_westend_runtime::xcm_config::PoolAssetsPalletLocation::get();
|
||||
asset_one.append_with(GeneralIndex(ASSET_ID.into())).expect("pool assets");
|
||||
|
||||
AssetHubWestend::execute_with(|| {
|
||||
let pool_owner_account_id = asset_hub_westend_runtime::AssetConversionOrigin::get();
|
||||
@@ -253,8 +254,8 @@ fn cannot_create_pool_from_pool_assets() {
|
||||
assert_matches::assert_matches!(
|
||||
<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::create_pool(
|
||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
||||
asset_native,
|
||||
Box::new(asset_one),
|
||||
Box::new(v3::Location::try_from(asset_native).expect("conversion works")),
|
||||
Box::new(v3::Location::try_from(asset_one).expect("conversion works")),
|
||||
),
|
||||
Err(DispatchError::Module(ModuleError{index: _, error: _, message})) => assert_eq!(message, Some("Unknown"))
|
||||
);
|
||||
@@ -263,7 +264,9 @@ fn cannot_create_pool_from_pool_assets() {
|
||||
|
||||
#[test]
|
||||
fn pay_xcm_fee_with_some_asset_swapped_for_native() {
|
||||
let asset_native = asset_hub_westend_runtime::xcm_config::WestendLocationV3::get();
|
||||
let asset_native =
|
||||
v3::Location::try_from(asset_hub_westend_runtime::xcm_config::WestendLocation::get())
|
||||
.expect("conversion works");
|
||||
let asset_one = xcm::v3::Location {
|
||||
parents: 0,
|
||||
interior: [
|
||||
|
||||
+17
-21
@@ -110,7 +110,7 @@ fn para_dest_assertions(t: RelayToSystemParaTest) {
|
||||
|
||||
fn penpal_to_ah_foreign_assets_sender_assertions(t: ParaToSystemParaTest) {
|
||||
type RuntimeEvent = <PenpalA as Chain>::RuntimeEvent;
|
||||
let system_para_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let system_para_native_asset_location = RelayLocation::get();
|
||||
let expected_asset_id = t.args.asset_id.unwrap();
|
||||
let (_, expected_asset_amount) =
|
||||
non_fee_asset(&t.args.assets, t.args.fee_asset_item as usize).unwrap();
|
||||
@@ -203,7 +203,7 @@ fn ah_to_penpal_foreign_assets_receiver_assertions(t: SystemParaToParaTest) {
|
||||
let (_, expected_asset_amount) =
|
||||
non_fee_asset(&t.args.assets, t.args.fee_asset_item as usize).unwrap();
|
||||
let checking_account = <PenpalA as PenpalAPallet>::PolkadotXcm::check_account();
|
||||
let system_para_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let system_para_native_asset_location = RelayLocation::get();
|
||||
|
||||
PenpalA::assert_xcmp_queue_success(None);
|
||||
|
||||
@@ -420,22 +420,20 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
) {
|
||||
// Init values for Parachain
|
||||
let fee_amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 100;
|
||||
let asset_location_on_penpal =
|
||||
v3::Location::try_from(PenpalLocalTeleportableToAssetHub::get()).unwrap();
|
||||
let asset_location_on_penpal = PenpalLocalTeleportableToAssetHub::get();
|
||||
let asset_id_on_penpal = match asset_location_on_penpal.last() {
|
||||
Some(v3::Junction::GeneralIndex(id)) => *id as u32,
|
||||
Some(Junction::GeneralIndex(id)) => *id as u32,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let asset_amount_to_send = ASSET_HUB_WESTEND_ED * 100;
|
||||
let asset_owner = PenpalAssetOwner::get();
|
||||
let system_para_native_asset_location = v3::Location::try_from(RelayLocation::get()).unwrap();
|
||||
let system_para_native_asset_location = RelayLocation::get();
|
||||
let sender = PenpalASender::get();
|
||||
let penpal_check_account = <PenpalA as PenpalAPallet>::PolkadotXcm::check_account();
|
||||
let ah_as_seen_by_penpal = PenpalA::sibling_location_of(AssetHubWestend::para_id());
|
||||
let asset_location_on_penpal_latest: Location = asset_location_on_penpal.try_into().unwrap();
|
||||
let penpal_assets: Assets = vec![
|
||||
(Parent, fee_amount_to_send).into(),
|
||||
(asset_location_on_penpal_latest, asset_amount_to_send).into(),
|
||||
(asset_location_on_penpal.clone(), asset_amount_to_send).into(),
|
||||
]
|
||||
.into();
|
||||
let fee_asset_index = penpal_assets
|
||||
@@ -447,7 +445,7 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
// fund Parachain's sender account
|
||||
PenpalA::mint_foreign_asset(
|
||||
<PenpalA as Chain>::RuntimeOrigin::signed(asset_owner.clone()),
|
||||
system_para_native_asset_location,
|
||||
system_para_native_asset_location.clone(),
|
||||
sender.clone(),
|
||||
fee_amount_to_send * 2,
|
||||
);
|
||||
@@ -474,7 +472,7 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
|
||||
// Init values for System Parachain
|
||||
let foreign_asset_at_asset_hub_westend =
|
||||
v3::Location::new(1, [v3::Junction::Parachain(PenpalA::para_id().into())])
|
||||
Location::new(1, [Junction::Parachain(PenpalA::para_id().into())])
|
||||
.appended_with(asset_location_on_penpal)
|
||||
.unwrap();
|
||||
let penpal_to_ah_beneficiary_id = AssetHubWestendReceiver::get();
|
||||
@@ -496,7 +494,7 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
let penpal_sender_balance_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
system_para_native_asset_location,
|
||||
system_para_native_asset_location.clone(),
|
||||
&PenpalASender::get(),
|
||||
)
|
||||
});
|
||||
@@ -510,7 +508,7 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
let ah_receiver_assets_before = AssetHubWestend::execute_with(|| {
|
||||
type Assets = <AssetHubWestend as AssetHubWestendPallet>::ForeignAssets;
|
||||
<Assets as Inspect<_>>::balance(
|
||||
foreign_asset_at_asset_hub_westend,
|
||||
foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(),
|
||||
&AssetHubWestendReceiver::get(),
|
||||
)
|
||||
});
|
||||
@@ -523,7 +521,7 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
let penpal_sender_balance_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
system_para_native_asset_location,
|
||||
system_para_native_asset_location.clone(),
|
||||
&PenpalASender::get(),
|
||||
)
|
||||
});
|
||||
@@ -537,7 +535,7 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
let ah_receiver_assets_after = AssetHubWestend::execute_with(|| {
|
||||
type Assets = <AssetHubWestend as AssetHubWestendPallet>::ForeignAssets;
|
||||
<Assets as Inspect<_>>::balance(
|
||||
foreign_asset_at_asset_hub_westend,
|
||||
foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(),
|
||||
&AssetHubWestendReceiver::get(),
|
||||
)
|
||||
});
|
||||
@@ -565,19 +563,17 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
type ForeignAssets = <AssetHubWestend as AssetHubWestendPallet>::ForeignAssets;
|
||||
assert_ok!(ForeignAssets::transfer(
|
||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendReceiver::get()),
|
||||
foreign_asset_at_asset_hub_westend,
|
||||
foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(),
|
||||
AssetHubWestendSender::get().into(),
|
||||
asset_amount_to_send,
|
||||
));
|
||||
});
|
||||
|
||||
let foreign_asset_at_asset_hub_westend_latest: Location =
|
||||
foreign_asset_at_asset_hub_westend.try_into().unwrap();
|
||||
let ah_to_penpal_beneficiary_id = PenpalAReceiver::get();
|
||||
let penpal_as_seen_by_ah = AssetHubWestend::sibling_location_of(PenpalA::para_id());
|
||||
let ah_assets: Assets = vec![
|
||||
(Parent, fee_amount_to_send).into(),
|
||||
(foreign_asset_at_asset_hub_westend_latest, asset_amount_to_send).into(),
|
||||
(foreign_asset_at_asset_hub_westend.clone(), asset_amount_to_send).into(),
|
||||
]
|
||||
.into();
|
||||
let fee_asset_index = ah_assets
|
||||
@@ -605,7 +601,7 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
let penpal_receiver_balance_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
system_para_native_asset_location,
|
||||
system_para_native_asset_location.clone(),
|
||||
&PenpalAReceiver::get(),
|
||||
)
|
||||
});
|
||||
@@ -613,7 +609,7 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
let ah_sender_assets_before = AssetHubWestend::execute_with(|| {
|
||||
type ForeignAssets = <AssetHubWestend as AssetHubWestendPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
foreign_asset_at_asset_hub_westend,
|
||||
foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(),
|
||||
&AssetHubWestendSender::get(),
|
||||
)
|
||||
});
|
||||
@@ -639,7 +635,7 @@ pub fn do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using
|
||||
let ah_sender_assets_after = AssetHubWestend::execute_with(|| {
|
||||
type ForeignAssets = <AssetHubWestend as AssetHubWestendPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
foreign_asset_at_asset_hub_westend,
|
||||
foreign_asset_at_asset_hub_westend.clone().try_into().unwrap(),
|
||||
&AssetHubWestendSender::get(),
|
||||
)
|
||||
});
|
||||
|
||||
+21
-19
@@ -168,9 +168,11 @@ fn send_rocs_from_asset_hub_rococo_to_asset_hub_westend() {
|
||||
<Assets as Inspect<_>>::balance(roc_at_asset_hub_westend, &AssetHubWestendReceiver::get())
|
||||
});
|
||||
|
||||
let roc_at_asset_hub_rococo_latest: Location = roc_at_asset_hub_rococo.try_into().unwrap();
|
||||
let amount = ASSET_HUB_ROCOCO_ED * 1_000_000;
|
||||
send_asset_from_asset_hub_rococo_to_asset_hub_westend(roc_at_asset_hub_rococo_latest, amount);
|
||||
send_asset_from_asset_hub_rococo_to_asset_hub_westend(
|
||||
roc_at_asset_hub_rococo.try_into().unwrap(),
|
||||
amount,
|
||||
);
|
||||
AssetHubWestend::execute_with(|| {
|
||||
type RuntimeEvent = <AssetHubWestend as Chain>::RuntimeEvent;
|
||||
assert_expected_events!(
|
||||
@@ -238,10 +240,9 @@ fn send_wnds_from_asset_hub_rococo_to_asset_hub_westend() {
|
||||
let receiver_wnds_before =
|
||||
<AssetHubWestend as Chain>::account_data_of(AssetHubWestendReceiver::get()).free;
|
||||
|
||||
let wnd_at_asset_hub_rococo_latest: Location = wnd_at_asset_hub_rococo.try_into().unwrap();
|
||||
let amount_to_send = ASSET_HUB_WESTEND_ED * 1_000;
|
||||
send_asset_from_asset_hub_rococo_to_asset_hub_westend(
|
||||
wnd_at_asset_hub_rococo_latest.clone(),
|
||||
Location::try_from(wnd_at_asset_hub_rococo).unwrap(),
|
||||
amount_to_send,
|
||||
);
|
||||
AssetHubWestend::execute_with(|| {
|
||||
@@ -287,13 +288,11 @@ fn send_wnds_from_asset_hub_rococo_to_asset_hub_westend() {
|
||||
|
||||
#[test]
|
||||
fn send_rocs_from_penpal_rococo_through_asset_hub_rococo_to_asset_hub_westend() {
|
||||
let roc_at_rococo_parachains: v3::Location = v3::Parent.into();
|
||||
let roc_at_asset_hub_westend =
|
||||
v3::Location::new(2, [v3::Junction::GlobalConsensus(v3::NetworkId::Rococo)]);
|
||||
let roc_at_rococo_parachains_latest: Location = roc_at_rococo_parachains.try_into().unwrap();
|
||||
let roc_at_rococo_parachains: Location = Parent.into();
|
||||
let roc_at_asset_hub_westend = Location::new(2, [Junction::GlobalConsensus(NetworkId::Rococo)]);
|
||||
let owner: AccountId = AssetHubWestend::account_id_of(ALICE);
|
||||
AssetHubWestend::force_create_foreign_asset(
|
||||
roc_at_asset_hub_westend,
|
||||
roc_at_asset_hub_westend.clone().try_into().unwrap(),
|
||||
owner,
|
||||
true,
|
||||
ASSET_MIN_BALANCE,
|
||||
@@ -312,7 +311,7 @@ fn send_rocs_from_penpal_rococo_through_asset_hub_rococo_to_asset_hub_westend()
|
||||
// fund Penpal's sender account
|
||||
PenpalA::mint_foreign_asset(
|
||||
<PenpalA as Chain>::RuntimeOrigin::signed(PenpalAssetOwner::get()),
|
||||
roc_at_rococo_parachains,
|
||||
roc_at_rococo_parachains.clone(),
|
||||
PenpalASender::get(),
|
||||
amount * 2,
|
||||
);
|
||||
@@ -322,16 +321,19 @@ fn send_rocs_from_penpal_rococo_through_asset_hub_rococo_to_asset_hub_westend()
|
||||
let sender_rocs_before = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
roc_at_rococo_parachains.into(),
|
||||
roc_at_rococo_parachains.clone(),
|
||||
&PenpalASender::get(),
|
||||
)
|
||||
});
|
||||
let receiver_rocs_before = AssetHubWestend::execute_with(|| {
|
||||
type Assets = <AssetHubWestend as AssetHubWestendPallet>::ForeignAssets;
|
||||
<Assets as Inspect<_>>::balance(roc_at_asset_hub_westend, &AssetHubWestendReceiver::get())
|
||||
<Assets as Inspect<_>>::balance(
|
||||
roc_at_asset_hub_westend.clone().try_into().unwrap(),
|
||||
&AssetHubWestendReceiver::get(),
|
||||
)
|
||||
});
|
||||
send_asset_from_penpal_rococo_through_local_asset_hub_to_westend_asset_hub(
|
||||
roc_at_rococo_parachains_latest,
|
||||
roc_at_rococo_parachains.clone(),
|
||||
amount,
|
||||
);
|
||||
|
||||
@@ -342,7 +344,7 @@ fn send_rocs_from_penpal_rococo_through_asset_hub_rococo_to_asset_hub_westend()
|
||||
vec![
|
||||
// issue ROCs on AHW
|
||||
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, .. }) => {
|
||||
asset_id: *asset_id == roc_at_rococo_parachains,
|
||||
asset_id: *asset_id == roc_at_rococo_parachains.clone().try_into().unwrap(),
|
||||
owner: *owner == AssetHubWestendReceiver::get(),
|
||||
},
|
||||
// message processed successfully
|
||||
@@ -355,14 +357,14 @@ fn send_rocs_from_penpal_rococo_through_asset_hub_rococo_to_asset_hub_westend()
|
||||
|
||||
let sender_rocs_after = PenpalA::execute_with(|| {
|
||||
type ForeignAssets = <PenpalA as PenpalAPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
roc_at_rococo_parachains.into(),
|
||||
&PenpalASender::get(),
|
||||
)
|
||||
<ForeignAssets as Inspect<_>>::balance(roc_at_rococo_parachains, &PenpalASender::get())
|
||||
});
|
||||
let receiver_rocs_after = AssetHubWestend::execute_with(|| {
|
||||
type Assets = <AssetHubWestend as AssetHubWestendPallet>::ForeignAssets;
|
||||
<Assets as Inspect<_>>::balance(roc_at_asset_hub_westend, &AssetHubWestendReceiver::get())
|
||||
<Assets as Inspect<_>>::balance(
|
||||
roc_at_asset_hub_westend.try_into().unwrap(),
|
||||
&AssetHubWestendReceiver::get(),
|
||||
)
|
||||
});
|
||||
let rocs_in_reserve_on_ahr_after =
|
||||
<AssetHubRococo as Chain>::account_data_of(sov_ahw_on_ahr.clone()).free;
|
||||
|
||||
+2
-4
@@ -306,8 +306,6 @@ fn send_token_from_ethereum_to_penpal() {
|
||||
// The Weth asset location, identified by the contract address on Ethereum
|
||||
let weth_asset_location: Location =
|
||||
(Parent, Parent, EthereumNetwork::get(), AccountKey20 { network: None, key: WETH }).into();
|
||||
// Converts the Weth asset location into an asset ID
|
||||
let weth_asset_id: v3::Location = weth_asset_location.try_into().unwrap();
|
||||
|
||||
let origin_location = (Parent, Parent, EthereumNetwork::get()).into();
|
||||
|
||||
@@ -321,12 +319,12 @@ fn send_token_from_ethereum_to_penpal() {
|
||||
PenpalA::execute_with(|| {
|
||||
assert_ok!(<PenpalA as PenpalAPallet>::ForeignAssets::create(
|
||||
<PenpalA as Chain>::RuntimeOrigin::signed(PenpalASender::get()),
|
||||
weth_asset_id,
|
||||
weth_asset_location.clone(),
|
||||
asset_hub_sovereign.into(),
|
||||
1000,
|
||||
));
|
||||
|
||||
assert!(<PenpalA as PenpalAPallet>::ForeignAssets::asset_exists(weth_asset_id));
|
||||
assert!(<PenpalA as PenpalAPallet>::ForeignAssets::asset_exists(weth_asset_location));
|
||||
});
|
||||
|
||||
BridgeHubRococo::execute_with(|| {
|
||||
|
||||
+17
-17
@@ -236,10 +236,9 @@ fn send_rocs_from_asset_hub_westend_to_asset_hub_rococo() {
|
||||
let receiver_rocs_before =
|
||||
<AssetHubRococo as Chain>::account_data_of(AssetHubRococoReceiver::get()).free;
|
||||
|
||||
let roc_at_asset_hub_westend_latest: Location = roc_at_asset_hub_westend.try_into().unwrap();
|
||||
let amount_to_send = ASSET_HUB_ROCOCO_ED * 1_000;
|
||||
send_asset_from_asset_hub_westend_to_asset_hub_rococo(
|
||||
roc_at_asset_hub_westend_latest.clone(),
|
||||
roc_at_asset_hub_westend.try_into().unwrap(),
|
||||
amount_to_send,
|
||||
);
|
||||
AssetHubRococo::execute_with(|| {
|
||||
@@ -285,13 +284,11 @@ fn send_rocs_from_asset_hub_westend_to_asset_hub_rococo() {
|
||||
|
||||
#[test]
|
||||
fn send_wnds_from_penpal_westend_through_asset_hub_westend_to_asset_hub_rococo() {
|
||||
let wnd_at_westend_parachains: v3::Location = v3::Parent.into();
|
||||
let wnd_at_asset_hub_rococo =
|
||||
v3::Location::new(2, [v3::Junction::GlobalConsensus(v3::NetworkId::Westend)]);
|
||||
let wnd_at_westend_parachains_latest: Location = wnd_at_westend_parachains.try_into().unwrap();
|
||||
let wnd_at_westend_parachains: Location = Parent.into();
|
||||
let wnd_at_asset_hub_rococo = Location::new(2, [Junction::GlobalConsensus(NetworkId::Westend)]);
|
||||
let owner: AccountId = AssetHubRococo::account_id_of(ALICE);
|
||||
AssetHubRococo::force_create_foreign_asset(
|
||||
wnd_at_asset_hub_rococo,
|
||||
wnd_at_asset_hub_rococo.clone().try_into().unwrap(),
|
||||
owner,
|
||||
true,
|
||||
ASSET_MIN_BALANCE,
|
||||
@@ -310,7 +307,7 @@ fn send_wnds_from_penpal_westend_through_asset_hub_westend_to_asset_hub_rococo()
|
||||
// fund Penpal's sender account
|
||||
PenpalB::mint_foreign_asset(
|
||||
<PenpalB as Chain>::RuntimeOrigin::signed(PenpalAssetOwner::get()),
|
||||
wnd_at_westend_parachains,
|
||||
wnd_at_westend_parachains.clone(),
|
||||
PenpalBSender::get(),
|
||||
amount * 2,
|
||||
);
|
||||
@@ -320,16 +317,19 @@ fn send_wnds_from_penpal_westend_through_asset_hub_westend_to_asset_hub_rococo()
|
||||
let sender_wnds_before = PenpalB::execute_with(|| {
|
||||
type ForeignAssets = <PenpalB as PenpalBPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
wnd_at_westend_parachains.into(),
|
||||
wnd_at_westend_parachains.clone(),
|
||||
&PenpalBSender::get(),
|
||||
)
|
||||
});
|
||||
let receiver_wnds_before = AssetHubRococo::execute_with(|| {
|
||||
type Assets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
|
||||
<Assets as Inspect<_>>::balance(wnd_at_asset_hub_rococo, &AssetHubRococoReceiver::get())
|
||||
<Assets as Inspect<_>>::balance(
|
||||
wnd_at_asset_hub_rococo.clone().try_into().unwrap(),
|
||||
&AssetHubRococoReceiver::get(),
|
||||
)
|
||||
});
|
||||
send_asset_from_penpal_westend_through_local_asset_hub_to_rococo_asset_hub(
|
||||
wnd_at_westend_parachains_latest,
|
||||
wnd_at_westend_parachains.clone(),
|
||||
amount,
|
||||
);
|
||||
|
||||
@@ -340,7 +340,7 @@ fn send_wnds_from_penpal_westend_through_asset_hub_westend_to_asset_hub_rococo()
|
||||
vec![
|
||||
// issue WNDs on AHR
|
||||
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, .. }) => {
|
||||
asset_id: *asset_id == wnd_at_westend_parachains,
|
||||
asset_id: *asset_id == wnd_at_westend_parachains.clone().try_into().unwrap(),
|
||||
owner: *owner == AssetHubRococoReceiver::get(),
|
||||
},
|
||||
// message processed successfully
|
||||
@@ -353,14 +353,14 @@ fn send_wnds_from_penpal_westend_through_asset_hub_westend_to_asset_hub_rococo()
|
||||
|
||||
let sender_wnds_after = PenpalB::execute_with(|| {
|
||||
type ForeignAssets = <PenpalB as PenpalBPallet>::ForeignAssets;
|
||||
<ForeignAssets as Inspect<_>>::balance(
|
||||
wnd_at_westend_parachains.into(),
|
||||
&PenpalBSender::get(),
|
||||
)
|
||||
<ForeignAssets as Inspect<_>>::balance(wnd_at_westend_parachains, &PenpalBSender::get())
|
||||
});
|
||||
let receiver_wnds_after = AssetHubRococo::execute_with(|| {
|
||||
type Assets = <AssetHubRococo as AssetHubRococoPallet>::ForeignAssets;
|
||||
<Assets as Inspect<_>>::balance(wnd_at_asset_hub_rococo, &AssetHubRococoReceiver::get())
|
||||
<Assets as Inspect<_>>::balance(
|
||||
wnd_at_asset_hub_rococo.try_into().unwrap(),
|
||||
&AssetHubRococoReceiver::get(),
|
||||
)
|
||||
});
|
||||
let wnds_in_reserve_on_ahw_after =
|
||||
<AssetHubWestend as Chain>::account_data_of(sov_ahr_on_ahw.clone()).free;
|
||||
|
||||
Reference in New Issue
Block a user