asset-hub-westend-integration-tests: add more asset transfers tests (#2488)

Just adds more tests.
This commit is contained in:
Adrian Catangiu
2023-11-27 14:22:13 +02:00
committed by GitHub
parent 2610450a18
commit 4298bc608f
16 changed files with 400 additions and 125 deletions
Generated
+2
View File
@@ -1028,6 +1028,7 @@ dependencies = [
"pallet-xcm", "pallet-xcm",
"parachains-common", "parachains-common",
"parity-scale-codec", "parity-scale-codec",
"penpal-runtime",
"polkadot-runtime-common", "polkadot-runtime-common",
"sp-runtime", "sp-runtime",
"staging-xcm", "staging-xcm",
@@ -11746,6 +11747,7 @@ dependencies = [
"serde_json", "serde_json",
"sp-core", "sp-core",
"sp-runtime", "sp-runtime",
"westend-emulated-chain",
] ]
[[package]] [[package]]
@@ -52,6 +52,6 @@ decl_test_parachains! {
// AssetHubRococo implementation // AssetHubRococo implementation
impl_accounts_helpers_for_parachain!(AssetHubRococo); impl_accounts_helpers_for_parachain!(AssetHubRococo);
impl_assert_events_helpers_for_parachain!(AssetHubRococo, false); impl_assert_events_helpers_for_parachain!(AssetHubRococo);
impl_assets_helpers_for_parachain!(AssetHubRococo, Rococo); impl_assets_helpers_for_parachain!(AssetHubRococo, Rococo);
impl_foreign_assets_helpers_for_parachain!(AssetHubRococo, Rococo); impl_foreign_assets_helpers_for_parachain!(AssetHubRococo, Rococo);
@@ -52,6 +52,6 @@ decl_test_parachains! {
// AssetHubWestend implementation // AssetHubWestend implementation
impl_accounts_helpers_for_parachain!(AssetHubWestend); impl_accounts_helpers_for_parachain!(AssetHubWestend);
impl_assert_events_helpers_for_parachain!(AssetHubWestend, false); impl_assert_events_helpers_for_parachain!(AssetHubWestend);
impl_assets_helpers_for_parachain!(AssetHubWestend, Westend); impl_assets_helpers_for_parachain!(AssetHubWestend, Westend);
impl_foreign_assets_helpers_for_parachain!(AssetHubWestend, Westend); impl_foreign_assets_helpers_for_parachain!(AssetHubWestend, Westend);
@@ -46,4 +46,4 @@ decl_test_parachains! {
// BridgeHubRococo implementation // BridgeHubRococo implementation
impl_accounts_helpers_for_parachain!(BridgeHubRococo); impl_accounts_helpers_for_parachain!(BridgeHubRococo);
impl_assert_events_helpers_for_parachain!(BridgeHubRococo, false); impl_assert_events_helpers_for_parachain!(BridgeHubRococo);
@@ -46,4 +46,4 @@ decl_test_parachains! {
// BridgeHubWestend implementation // BridgeHubWestend implementation
impl_accounts_helpers_for_parachain!(BridgeHubWestend); impl_accounts_helpers_for_parachain!(BridgeHubWestend);
impl_assert_events_helpers_for_parachain!(BridgeHubWestend, false); impl_assert_events_helpers_for_parachain!(BridgeHubWestend);
@@ -23,3 +23,4 @@ cumulus-primitives-core = { path = "../../../../../../../primitives/core", defau
emulated-integration-tests-common = { path = "../../../../common", default-features = false } emulated-integration-tests-common = { path = "../../../../common", default-features = false }
penpal-runtime = { path = "../../../../../../runtimes/testing/penpal" } penpal-runtime = { path = "../../../../../../runtimes/testing/penpal" }
rococo-emulated-chain = { path = "../../../relays/rococo" } rococo-emulated-chain = { path = "../../../relays/rococo" }
westend-emulated-chain = { path = "../../../relays/westend" }
@@ -25,6 +25,7 @@ use emulated_integration_tests_common::{
impl_assets_helpers_for_parachain, impls::Parachain, xcm_emulator::decl_test_parachains, impl_assets_helpers_for_parachain, impls::Parachain, xcm_emulator::decl_test_parachains,
}; };
use rococo_emulated_chain::Rococo; use rococo_emulated_chain::Rococo;
use westend_emulated_chain::Westend;
// Penpal Parachain declaration // Penpal Parachain declaration
decl_test_parachains! { decl_test_parachains! {
@@ -67,5 +68,6 @@ decl_test_parachains! {
// Penpal implementation // Penpal implementation
impl_accounts_helpers_for_parachain!(PenpalA); impl_accounts_helpers_for_parachain!(PenpalA);
impl_assets_helpers_for_parachain!(PenpalA, Rococo); impl_assets_helpers_for_parachain!(PenpalA, Rococo);
impl_assert_events_helpers_for_parachain!(PenpalA, true); impl_assets_helpers_for_parachain!(PenpalB, Westend);
impl_assert_events_helpers_for_parachain!(PenpalB, true); impl_assert_events_helpers_for_parachain!(PenpalA);
impl_assert_events_helpers_for_parachain!(PenpalB);
@@ -418,7 +418,7 @@ macro_rules! impl_accounts_helpers_for_parachain {
#[macro_export] #[macro_export]
macro_rules! impl_assert_events_helpers_for_parachain { macro_rules! impl_assert_events_helpers_for_parachain {
( $chain:ident, $ignore_weight:expr ) => { ( $chain:ident ) => {
$crate::impls::paste::paste! { $crate::impls::paste::paste! {
type [<$chain RuntimeEvent>]<N> = <$chain<N> as $crate::impls::Chain>::RuntimeEvent; type [<$chain RuntimeEvent>]<N> = <$chain<N> as $crate::impls::Chain>::RuntimeEvent;
@@ -431,7 +431,7 @@ macro_rules! impl_assert_events_helpers_for_parachain {
[<$chain RuntimeEvent>]::<N>::PolkadotXcm( [<$chain RuntimeEvent>]::<N>::PolkadotXcm(
$crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Complete(weight) } $crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Complete(weight) }
) => { ) => {
weight: $ignore_weight || $crate::impls::weight_within_threshold( weight: $crate::impls::weight_within_threshold(
($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD),
expected_weight.unwrap_or(*weight), expected_weight.unwrap_or(*weight),
*weight *weight
@@ -453,7 +453,7 @@ macro_rules! impl_assert_events_helpers_for_parachain {
[<$chain RuntimeEvent>]::<N>::PolkadotXcm( [<$chain RuntimeEvent>]::<N>::PolkadotXcm(
$crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Incomplete(weight, error) } $crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Incomplete(weight, error) }
) => { ) => {
weight: $ignore_weight || $crate::impls::weight_within_threshold( weight: $crate::impls::weight_within_threshold(
($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD),
expected_weight.unwrap_or(*weight), expected_weight.unwrap_or(*weight),
*weight *weight
@@ -509,7 +509,7 @@ macro_rules! impl_assert_events_helpers_for_parachain {
[<$chain RuntimeEvent>]::<N>::MessageQueue($crate::impls::pallet_message_queue::Event::Processed { [<$chain RuntimeEvent>]::<N>::MessageQueue($crate::impls::pallet_message_queue::Event::Processed {
success: true, weight_used: weight, .. success: true, weight_used: weight, ..
}) => { }) => {
weight: $ignore_weight || $crate::impls::weight_within_threshold( weight: $crate::impls::weight_within_threshold(
($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD),
expected_weight.unwrap_or(*weight), expected_weight.unwrap_or(*weight),
*weight *weight
@@ -529,7 +529,7 @@ macro_rules! impl_assert_events_helpers_for_parachain {
[<$chain RuntimeEvent>]::<N>::MessageQueue($crate::impls::pallet_message_queue::Event::Processed { [<$chain RuntimeEvent>]::<N>::MessageQueue($crate::impls::pallet_message_queue::Event::Processed {
success: false, weight_used: weight, .. success: false, weight_used: weight, ..
}) => { }) => {
weight: $ignore_weight || $crate::impls::weight_within_threshold( weight: $crate::impls::weight_within_threshold(
($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD),
expected_weight.unwrap_or(*weight), expected_weight.unwrap_or(*weight),
*weight *weight
@@ -560,7 +560,7 @@ macro_rules! impl_assert_events_helpers_for_parachain {
vec![ vec![
[<$chain RuntimeEvent>]::<N>::MessageQueue($crate::impls::pallet_message_queue::Event::Processed { success: true, weight_used: weight, .. } [<$chain RuntimeEvent>]::<N>::MessageQueue($crate::impls::pallet_message_queue::Event::Processed { success: true, weight_used: weight, .. }
) => { ) => {
weight: $ignore_weight || $crate::impls::weight_within_threshold( weight: $crate::impls::weight_within_threshold(
($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD), ($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD),
expected_weight.unwrap_or(*weight), expected_weight.unwrap_or(*weight),
*weight *weight
@@ -40,19 +40,6 @@ fn relay_to_para_sender_assertions(t: RelayToParaTest) {
); );
} }
fn relay_to_para_receiver_assertions<Test>(_: Test) {
type RuntimeEvent = <PenpalA as Chain>::RuntimeEvent;
assert_expected_events!(
PenpalA,
vec![
RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {},
RuntimeEvent::MessageQueue(
pallet_message_queue::Event::Processed { success: true, .. }
) => {},
]
);
}
fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) { fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) {
type RuntimeEvent = <AssetHubRococo as Chain>::RuntimeEvent; type RuntimeEvent = <AssetHubRococo as Chain>::RuntimeEvent;
@@ -78,7 +65,7 @@ fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) {
); );
} }
fn system_para_to_para_receiver_assertions<Test>(_: Test) { fn para_receiver_assertions<Test>(_: Test) {
type RuntimeEvent = <PenpalA as Chain>::RuntimeEvent; type RuntimeEvent = <PenpalA as Chain>::RuntimeEvent;
assert_expected_events!( assert_expected_events!(
PenpalA, PenpalA,
@@ -297,7 +284,7 @@ fn reserve_transfer_native_asset_from_relay_to_para() {
let receiver_balance_before = test.receiver.balance; let receiver_balance_before = test.receiver.balance;
test.set_assertion::<Rococo>(relay_to_para_sender_assertions); test.set_assertion::<Rococo>(relay_to_para_sender_assertions);
test.set_assertion::<PenpalA>(relay_to_para_receiver_assertions); test.set_assertion::<PenpalA>(para_receiver_assertions);
test.set_dispatchable::<Rococo>(relay_to_para_limited_reserve_transfer_assets); test.set_dispatchable::<Rococo>(relay_to_para_limited_reserve_transfer_assets);
test.assert(); test.assert();
@@ -314,6 +301,10 @@ fn reserve_transfer_native_asset_from_relay_to_para() {
assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after); assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after);
// Receiver's balance is increased // Receiver's balance is increased
assert!(receiver_balance_after > receiver_balance_before); assert!(receiver_balance_after > receiver_balance_before);
// Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`;
// `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown but
// should be non-zero
assert!(receiver_balance_after < receiver_balance_before + amount_to_send);
} }
/// Reserve Transfers of native asset from System Parachain to Parachain should work /// Reserve Transfers of native asset from System Parachain to Parachain should work
@@ -337,7 +328,7 @@ fn reserve_transfer_native_asset_from_system_para_to_para() {
let receiver_balance_before = test.receiver.balance; let receiver_balance_before = test.receiver.balance;
test.set_assertion::<AssetHubRococo>(system_para_to_para_sender_assertions); test.set_assertion::<AssetHubRococo>(system_para_to_para_sender_assertions);
test.set_assertion::<PenpalA>(system_para_to_para_receiver_assertions); test.set_assertion::<PenpalA>(para_receiver_assertions);
test.set_dispatchable::<AssetHubRococo>(system_para_to_para_limited_reserve_transfer_assets); test.set_dispatchable::<AssetHubRococo>(system_para_to_para_limited_reserve_transfer_assets);
test.assert(); test.assert();
@@ -354,6 +345,10 @@ fn reserve_transfer_native_asset_from_system_para_to_para() {
assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after); assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after);
// Receiver's balance is increased // Receiver's balance is increased
assert!(receiver_balance_after > receiver_balance_before); assert!(receiver_balance_after > receiver_balance_before);
// Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`;
// `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown but
// should be non-zero
assert!(receiver_balance_after < receiver_balance_before + amount_to_send);
} }
/// Reserve Transfers of native asset from Parachain to System Parachain should work /// Reserve Transfers of native asset from Parachain to System Parachain should work
@@ -400,6 +395,10 @@ fn reserve_transfer_native_asset_from_para_to_system_para() {
assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after); assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after);
// Receiver's balance is increased // Receiver's balance is increased
assert!(receiver_balance_after > receiver_balance_before); assert!(receiver_balance_after > receiver_balance_before);
// Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`;
// `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown but
// should be non-zero
assert!(receiver_balance_after < receiver_balance_before + amount_to_send);
} }
/// Reserve Transfers of a local asset and native asset from System Parachain to Parachain should /// Reserve Transfers of a local asset and native asset from System Parachain to Parachain should
@@ -420,7 +419,7 @@ fn reserve_transfer_assets_from_system_para_to_para() {
ASSET_MIN_BALANCE, ASSET_MIN_BALANCE,
false, false,
PenpalASender::get(), PenpalASender::get(),
Some(Weight::from_parts(1_019_445_000, 200_000)), None,
0, 0,
); );
@@ -485,6 +484,10 @@ fn reserve_transfer_assets_from_system_para_to_para() {
assert!(sender_balance_after < sender_balance_before); assert!(sender_balance_after < sender_balance_before);
// Receiver's balance is increased // Receiver's balance is increased
assert!(receiver_balance_after > receiver_balance_before); assert!(receiver_balance_after > receiver_balance_before);
// Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`;
// `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown but
// should be non-zero
assert!(receiver_balance_after < receiver_balance_before + fee_amount_to_send);
let sender_assets_after = AssetHubRococo::execute_with(|| { let sender_assets_after = AssetHubRococo::execute_with(|| {
type Assets = <AssetHubRococo as AssetHubRococoPallet>::Assets; type Assets = <AssetHubRococo as AssetHubRococoPallet>::Assets;
@@ -495,8 +498,8 @@ fn reserve_transfer_assets_from_system_para_to_para() {
<Assets as Inspect<_>>::balance(ASSET_ID, &PenpalAReceiver::get()) <Assets as Inspect<_>>::balance(ASSET_ID, &PenpalAReceiver::get())
}); });
// Sender's balance is reduced // Sender's balance is reduced by exact amount
assert_eq!(sender_assets_before - asset_amount_to_send, sender_assets_after); assert_eq!(sender_assets_before - asset_amount_to_send, sender_assets_after);
// Receiver's balance is increased // Receiver's balance is increased by exact amount
assert!(receiver_assets_after > receiver_assets_before); assert_eq!(receiver_assets_after, receiver_assets_before + asset_amount_to_send);
} }
@@ -44,12 +44,6 @@ fn swap_locally_on_chain_using_local_assets() {
100_000_000_000_000, 100_000_000_000_000,
)); ));
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::Balances::force_set_balance(
<AssetHubRococo as Chain>::RuntimeOrigin::root(),
AssetHubRococoSender::get().into(),
100_000_000_000_000,
));
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::create_pool( assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::create_pool(
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()), <AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
asset_native.clone(), asset_native.clone(),
@@ -38,4 +38,5 @@ asset-test-utils = { path = "../../../../../runtimes/assets/test-utils" }
cumulus-pallet-dmp-queue = { default-features = false, path = "../../../../../../pallets/dmp-queue" } cumulus-pallet-dmp-queue = { default-features = false, path = "../../../../../../pallets/dmp-queue" }
cumulus-pallet-parachain-system = { default-features = false, path = "../../../../../../pallets/parachain-system" } cumulus-pallet-parachain-system = { default-features = false, path = "../../../../../../pallets/parachain-system" }
emulated-integration-tests-common = { path = "../../../common", default-features = false} emulated-integration-tests-common = { path = "../../../common", default-features = false}
penpal-runtime = { path = "../../../../../runtimes/testing/penpal" }
westend-system-emulated-network ={ path = "../../../networks/westend-system" } westend-system-emulated-network ={ path = "../../../networks/westend-system" }
@@ -47,11 +47,12 @@ pub use westend_system_emulated_network::{
asset_hub_westend_emulated_chain::{ asset_hub_westend_emulated_chain::{
genesis::ED as ASSET_HUB_WESTEND_ED, AssetHubWestendParaPallet as AssetHubWestendPallet, genesis::ED as ASSET_HUB_WESTEND_ED, AssetHubWestendParaPallet as AssetHubWestendPallet,
}, },
penpal_emulated_chain::PenpalAParaPallet as PenpalAPallet, penpal_emulated_chain::PenpalBParaPallet as PenpalBPallet,
westend_emulated_chain::{genesis::ED as WESTEND_ED, WestendRelayPallet as WestendPallet}, westend_emulated_chain::{genesis::ED as WESTEND_ED, WestendRelayPallet as WestendPallet},
AssetHubWestendPara as AssetHubWestend, AssetHubWestendParaReceiver as AssetHubWestendReceiver, AssetHubWestendPara as AssetHubWestend, AssetHubWestendParaReceiver as AssetHubWestendReceiver,
AssetHubWestendParaSender as AssetHubWestendSender, PenpalAPara as PenpalA, AssetHubWestendParaSender as AssetHubWestendSender, BridgeHubWestendPara as BridgeHubWestend,
PenpalAParaReceiver as PenpalAReceiver, PenpalAParaSender as PenpalASender, BridgeHubWestendParaReceiver as BridgeHubWestendReceiver, PenpalBPara as PenpalB,
PenpalBParaReceiver as PenpalBReceiver, PenpalBParaSender as PenpalBSender,
WestendRelay as Westend, WestendRelayReceiver as WestendReceiver, WestendRelay as Westend, WestendRelayReceiver as WestendReceiver,
WestendRelaySender as WestendSender, WestendRelaySender as WestendSender,
}; };
@@ -62,18 +63,20 @@ pub const ASSET_MIN_BALANCE: u128 = 1000;
pub const ASSETS_PALLET_ID: u8 = 50; pub const ASSETS_PALLET_ID: u8 = 50;
pub type RelayToSystemParaTest = Test<Westend, AssetHubWestend>; pub type RelayToSystemParaTest = Test<Westend, AssetHubWestend>;
pub type RelayToParaTest = Test<Westend, PenpalB>;
pub type SystemParaToRelayTest = Test<AssetHubWestend, Westend>; pub type SystemParaToRelayTest = Test<AssetHubWestend, Westend>;
pub type SystemParaToParaTest = Test<AssetHubWestend, PenpalA>; pub type SystemParaToParaTest = Test<AssetHubWestend, PenpalB>;
pub type ParaToSystemParaTest = Test<PenpalB, AssetHubWestend>;
/// Returns a `TestArgs` instance to be used for the Relay Chain across integration tests /// Returns a `TestArgs` instance to be used for the Relay Chain across integration tests
pub fn relay_test_args(amount: Balance) -> TestArgs { pub fn relay_test_args(
dest: MultiLocation,
beneficiary_id: AccountId32,
amount: Balance,
) -> TestArgs {
TestArgs { TestArgs {
dest: Westend::child_location_of(AssetHubWestend::para_id()), dest,
beneficiary: AccountId32Junction { beneficiary: AccountId32Junction { network: None, id: beneficiary_id.into() }.into(),
network: None,
id: AssetHubWestendReceiver::get().into(),
}
.into(),
amount, amount,
assets: (Here, amount).into(), assets: (Here, amount).into(),
asset_id: None, asset_id: None,
@@ -82,13 +85,14 @@ pub fn relay_test_args(amount: Balance) -> TestArgs {
} }
} }
/// Returns a `TestArgs` instance to be used for the System Parachain across integration tests /// Returns a `TestArgs` instance to be used by parachains across integration tests
pub fn system_para_test_args( pub fn para_test_args(
dest: MultiLocation, dest: MultiLocation,
beneficiary_id: AccountId32, beneficiary_id: AccountId32,
amount: Balance, amount: Balance,
assets: MultiAssets, assets: MultiAssets,
asset_id: Option<u32>, asset_id: Option<u32>,
fee_asset_item: u32,
) -> TestArgs { ) -> TestArgs {
TestArgs { TestArgs {
dest, dest,
@@ -96,7 +100,7 @@ pub fn system_para_test_args(
amount, amount,
assets, assets,
asset_id, asset_id,
fee_asset_item: 0, fee_asset_item,
weight_limit: WeightLimit::Unlimited, weight_limit: WeightLimit::Unlimited,
} }
} }
@@ -14,7 +14,31 @@
// limitations under the License. // limitations under the License.
use crate::*; use crate::*;
use asset_hub_westend_runtime::xcm_config::XcmConfig; use asset_hub_westend_runtime::xcm_config::XcmConfig as AssetHubWestendXcmConfig;
use penpal_runtime::xcm_config::XcmConfig as PenpalWestendXcmConfig;
use westend_runtime::xcm_config::XcmConfig as WestendXcmConfig;
fn relay_to_para_sender_assertions(t: RelayToParaTest) {
type RuntimeEvent = <Westend as Chain>::RuntimeEvent;
Westend::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(864_610_000, 8_799)));
assert_expected_events!(
Westend,
vec![
// Amount to reserve transfer is transferred to Parachain's Sovereign account
RuntimeEvent::Balances(
pallet_balances::Event::Transfer { from, to, amount }
) => {
from: *from == t.sender.account_id,
to: *to == Westend::sovereign_account_id_of(
t.args.dest
),
amount: *amount == t.args.amount,
},
]
);
}
fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) { fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) {
type RuntimeEvent = <AssetHubWestend as Chain>::RuntimeEvent; type RuntimeEvent = <AssetHubWestend as Chain>::RuntimeEvent;
@@ -42,9 +66,9 @@ fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) {
} }
fn para_receiver_assertions<Test>(_: Test) { fn para_receiver_assertions<Test>(_: Test) {
type RuntimeEvent = <PenpalA as Chain>::RuntimeEvent; type RuntimeEvent = <PenpalB as Chain>::RuntimeEvent;
assert_expected_events!( assert_expected_events!(
PenpalA, PenpalB,
vec![ vec![
RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {}, RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {},
RuntimeEvent::MessageQueue( RuntimeEvent::MessageQueue(
@@ -54,7 +78,51 @@ fn para_receiver_assertions<Test>(_: Test) {
); );
} }
fn system_para_to_para_assets_assertions(t: SystemParaToParaTest) { fn para_to_system_para_sender_assertions(t: ParaToSystemParaTest) {
type RuntimeEvent = <PenpalB as Chain>::RuntimeEvent;
PenpalB::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(864_610_000, 8_799)));
assert_expected_events!(
PenpalB,
vec![
// Amount to reserve transfer is transferred to Parachain's Sovereign account
RuntimeEvent::Balances(
pallet_balances::Event::Withdraw { who, amount }
) => {
who: *who == t.sender.account_id,
amount: *amount == t.args.amount,
},
]
);
}
fn para_to_system_para_receiver_assertions(t: ParaToSystemParaTest) {
type RuntimeEvent = <AssetHubWestend as Chain>::RuntimeEvent;
let sov_penpal_on_ahw = AssetHubWestend::sovereign_account_id_of(
AssetHubWestend::sibling_location_of(PenpalB::para_id()),
);
assert_expected_events!(
AssetHubWestend,
vec![
// Amount to reserve transfer is transferred to Parachain's Sovereign account
RuntimeEvent::Balances(
pallet_balances::Event::Withdraw { who, amount }
) => {
who: *who == sov_penpal_on_ahw.clone().into(),
amount: *amount == t.args.amount,
},
RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {},
RuntimeEvent::MessageQueue(
pallet_message_queue::Event::Processed { success: true, .. }
) => {},
]
);
}
fn system_para_to_para_assets_sender_assertions(t: SystemParaToParaTest) {
type RuntimeEvent = <AssetHubWestend as Chain>::RuntimeEvent; type RuntimeEvent = <AssetHubWestend as Chain>::RuntimeEvent;
AssetHubWestend::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts( AssetHubWestend::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(
@@ -80,6 +148,31 @@ fn system_para_to_para_assets_assertions(t: SystemParaToParaTest) {
); );
} }
fn system_para_to_para_assets_receiver_assertions<Test>(_: Test) {
type RuntimeEvent = <PenpalB as Chain>::RuntimeEvent;
assert_expected_events!(
PenpalB,
vec![
RuntimeEvent::Balances(pallet_balances::Event::Deposit { .. }) => {},
RuntimeEvent::Assets(pallet_assets::Event::Issued { .. }) => {},
RuntimeEvent::MessageQueue(
pallet_message_queue::Event::Processed { success: true, .. }
) => {},
]
);
}
fn relay_to_para_limited_reserve_transfer_assets(t: RelayToParaTest) -> DispatchResult {
<Westend as WestendPallet>::XcmPallet::limited_reserve_transfer_assets(
t.signed_origin,
bx!(t.args.dest.into()),
bx!(t.args.beneficiary.into()),
bx!(t.args.assets.into()),
t.args.fee_asset_item,
t.args.weight_limit,
)
}
fn system_para_to_para_limited_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult { fn system_para_to_para_limited_reserve_transfer_assets(t: SystemParaToParaTest) -> DispatchResult {
<AssetHubWestend as AssetHubWestendPallet>::PolkadotXcm::limited_reserve_transfer_assets( <AssetHubWestend as AssetHubWestendPallet>::PolkadotXcm::limited_reserve_transfer_assets(
t.signed_origin, t.signed_origin,
@@ -91,6 +184,17 @@ fn system_para_to_para_limited_reserve_transfer_assets(t: SystemParaToParaTest)
) )
} }
fn para_to_system_para_limited_reserve_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult {
<PenpalB as PenpalBPallet>::PolkadotXcm::limited_reserve_transfer_assets(
t.signed_origin,
bx!(t.args.dest.into()),
bx!(t.args.beneficiary.into()),
bx!(t.args.assets.into()),
t.args.fee_asset_item,
t.args.weight_limit,
)
}
/// Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't work /// Reserve Transfers of native asset from Relay Chain to the System Parachain shouldn't work
#[test] #[test]
fn reserve_transfer_native_asset_from_relay_to_system_para_fails() { fn reserve_transfer_native_asset_from_relay_to_system_para_fails() {
@@ -159,19 +263,62 @@ fn reserve_transfer_native_asset_from_system_para_to_relay_fails() {
}); });
} }
/// Reserve Transfers of native asset from Relay to Parachain should work
#[test]
fn reserve_transfer_native_asset_from_relay_to_para() {
// Init values for Relay
let destination = Westend::child_location_of(PenpalB::para_id());
let beneficiary_id = PenpalBReceiver::get();
let amount_to_send: Balance = WESTEND_ED * 1000;
let test_args = TestContext {
sender: WestendSender::get(),
receiver: PenpalBReceiver::get(),
args: relay_test_args(destination, beneficiary_id, amount_to_send),
};
let mut test = RelayToParaTest::new(test_args);
let sender_balance_before = test.sender.balance;
let receiver_balance_before = test.receiver.balance;
test.set_assertion::<Westend>(relay_to_para_sender_assertions);
test.set_assertion::<PenpalB>(para_receiver_assertions);
test.set_dispatchable::<Westend>(relay_to_para_limited_reserve_transfer_assets);
test.assert();
let delivery_fees = Westend::execute_with(|| {
xcm_helpers::transfer_assets_delivery_fees::<
<WestendXcmConfig as xcm_executor::Config>::XcmSender,
>(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest)
});
let sender_balance_after = test.sender.balance;
let receiver_balance_after = test.receiver.balance;
// Sender's balance is reduced
assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after);
// Receiver's balance is increased
assert!(receiver_balance_after > receiver_balance_before);
// Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`;
// `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown but
// should be non-zero
assert!(receiver_balance_after < receiver_balance_before + amount_to_send);
}
/// Reserve Transfers of native asset from System Parachain to Parachain should work /// Reserve Transfers of native asset from System Parachain to Parachain should work
#[test] #[test]
fn reserve_transfer_native_asset_from_system_para_to_para() { fn reserve_transfer_native_asset_from_system_para_to_para() {
// Init values for System Parachain // Init values for System Parachain
let destination = AssetHubWestend::sibling_location_of(PenpalA::para_id()); let destination = AssetHubWestend::sibling_location_of(PenpalB::para_id());
let beneficiary_id = PenpalAReceiver::get(); let beneficiary_id = PenpalBReceiver::get();
let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000; let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000;
let assets = (Parent, amount_to_send).into(); let assets = (Parent, amount_to_send).into();
let test_args = TestContext { let test_args = TestContext {
sender: AssetHubWestendSender::get(), sender: AssetHubWestendSender::get(),
receiver: PenpalAReceiver::get(), receiver: PenpalBReceiver::get(),
args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), args: para_test_args(destination, beneficiary_id, amount_to_send, assets, None, 0),
}; };
let mut test = SystemParaToParaTest::new(test_args); let mut test = SystemParaToParaTest::new(test_args);
@@ -180,7 +327,7 @@ fn reserve_transfer_native_asset_from_system_para_to_para() {
let receiver_balance_before = test.receiver.balance; let receiver_balance_before = test.receiver.balance;
test.set_assertion::<AssetHubWestend>(system_para_to_para_sender_assertions); test.set_assertion::<AssetHubWestend>(system_para_to_para_sender_assertions);
test.set_assertion::<PenpalA>(para_receiver_assertions); test.set_assertion::<PenpalB>(para_receiver_assertions);
test.set_dispatchable::<AssetHubWestend>(system_para_to_para_limited_reserve_transfer_assets); test.set_dispatchable::<AssetHubWestend>(system_para_to_para_limited_reserve_transfer_assets);
test.assert(); test.assert();
@@ -188,53 +335,171 @@ fn reserve_transfer_native_asset_from_system_para_to_para() {
let receiver_balance_after = test.receiver.balance; let receiver_balance_after = test.receiver.balance;
let delivery_fees = AssetHubWestend::execute_with(|| { let delivery_fees = AssetHubWestend::execute_with(|| {
xcm_helpers::transfer_assets_delivery_fees::<<XcmConfig as xcm_executor::Config>::XcmSender>( xcm_helpers::transfer_assets_delivery_fees::<
test.args.assets.clone(), <AssetHubWestendXcmConfig as xcm_executor::Config>::XcmSender,
0, >(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest)
test.args.weight_limit,
test.args.beneficiary,
test.args.dest,
)
}); });
// Sender's balance is reduced // Sender's balance is reduced
assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after); assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after);
// Receiver's balance is increased // Receiver's balance is increased
assert!(receiver_balance_after > receiver_balance_before); assert!(receiver_balance_after > receiver_balance_before);
// Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`;
// `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown but
// should be non-zero
assert!(receiver_balance_after < receiver_balance_before + amount_to_send);
} }
/// Reserve Transfers of a local asset from System Parachain to Parachain should work /// Reserve Transfers of native asset from Parachain to System Parachain should work
#[test] #[test]
fn reserve_transfer_asset_from_system_para_to_para() { fn reserve_transfer_native_asset_from_para_to_system_para() {
// Force create asset from Relay Chain and mint assets for System Parachain's sender account // Init values for Penpal Parachain
let destination = PenpalB::sibling_location_of(AssetHubWestend::para_id());
let beneficiary_id = AssetHubWestendReceiver::get();
let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000;
let assets = (Parent, amount_to_send).into();
let test_args = TestContext {
sender: PenpalBSender::get(),
receiver: AssetHubWestendReceiver::get(),
args: para_test_args(destination, beneficiary_id, amount_to_send, assets, None, 0),
};
let mut test = ParaToSystemParaTest::new(test_args);
let sender_balance_before = test.sender.balance;
let receiver_balance_before = test.receiver.balance;
let penpal_location_as_seen_by_ahw = AssetHubWestend::sibling_location_of(PenpalB::para_id());
let sov_penpal_on_ahw =
AssetHubWestend::sovereign_account_id_of(penpal_location_as_seen_by_ahw);
// fund the Penpal's SA on AHW with the native tokens held in reserve
AssetHubWestend::fund_accounts(vec![(sov_penpal_on_ahw.into(), amount_to_send * 2)]);
test.set_assertion::<PenpalB>(para_to_system_para_sender_assertions);
test.set_assertion::<AssetHubWestend>(para_to_system_para_receiver_assertions);
test.set_dispatchable::<PenpalB>(para_to_system_para_limited_reserve_transfer_assets);
test.assert();
let sender_balance_after = test.sender.balance;
let receiver_balance_after = test.receiver.balance;
let delivery_fees = PenpalB::execute_with(|| {
xcm_helpers::transfer_assets_delivery_fees::<
<PenpalWestendXcmConfig as xcm_executor::Config>::XcmSender,
>(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest)
});
// Sender's balance is reduced
assert_eq!(sender_balance_before - amount_to_send - delivery_fees, sender_balance_after);
// Receiver's balance is increased
assert!(receiver_balance_after > receiver_balance_before);
// Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`;
// `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown but
// should be non-zero
assert!(receiver_balance_after < receiver_balance_before + amount_to_send);
}
/// Reserve Transfers of a local asset and native asset from System Parachain to Parachain should
/// work
#[test]
fn reserve_transfer_assets_from_system_para_to_para() {
// Force create asset on AssetHubWestend and PenpalB from Relay Chain
AssetHubWestend::force_create_and_mint_asset( AssetHubWestend::force_create_and_mint_asset(
ASSET_ID, ASSET_ID,
ASSET_MIN_BALANCE, ASSET_MIN_BALANCE,
true, true,
AssetHubWestendSender::get(), AssetHubWestendSender::get(),
Some(Weight::from_parts(1_019_445_000, 200_000)), Some(Weight::from_parts(1_019_445_000, 200_000)),
ASSET_MIN_BALANCE * 1000000, ASSET_MIN_BALANCE * 1_000_000,
);
PenpalB::force_create_and_mint_asset(
ASSET_ID,
ASSET_MIN_BALANCE,
false,
PenpalBSender::get(),
None,
0,
); );
// Init values for System Parachain // Init values for System Parachain
let destination = AssetHubWestend::sibling_location_of(PenpalA::para_id()); let destination = AssetHubWestend::sibling_location_of(PenpalB::para_id());
let beneficiary_id = PenpalAReceiver::get(); let beneficiary_id = PenpalBReceiver::get();
let amount_to_send = ASSET_MIN_BALANCE * 1000; let fee_amount_to_send = ASSET_HUB_WESTEND_ED * 1000;
let assets = let asset_amount_to_send = ASSET_MIN_BALANCE * 1000;
(X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), amount_to_send) let assets: MultiAssets = vec![
.into(); (Parent, fee_amount_to_send).into(),
(X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), asset_amount_to_send)
.into(),
]
.into();
let fee_asset_index = assets
.inner()
.iter()
.position(|r| r == &(Parent, fee_amount_to_send).into())
.unwrap() as u32;
let system_para_test_args = TestContext { let para_test_args = TestContext {
sender: AssetHubWestendSender::get(), sender: AssetHubWestendSender::get(),
receiver: PenpalAReceiver::get(), receiver: PenpalBReceiver::get(),
args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), args: para_test_args(
destination,
beneficiary_id,
asset_amount_to_send,
assets,
None,
fee_asset_index,
),
}; };
let mut system_para_test = SystemParaToParaTest::new(system_para_test_args); let mut test = SystemParaToParaTest::new(para_test_args);
system_para_test.set_assertion::<AssetHubWestend>(system_para_to_para_assets_assertions); // Create SA-of-Penpal-on-AHW with ED.
// TODO: Add assertions when Penpal is able to manage assets let penpal_location = AssetHubWestend::sibling_location_of(PenpalB::para_id());
system_para_test let sov_penpal_on_ahw = AssetHubWestend::sovereign_account_id_of(penpal_location);
.set_dispatchable::<AssetHubWestend>(system_para_to_para_limited_reserve_transfer_assets); AssetHubWestend::fund_accounts(vec![(sov_penpal_on_ahw.into(), WESTEND_ED)]);
system_para_test.assert();
let sender_balance_before = test.sender.balance;
let receiver_balance_before = test.receiver.balance;
let sender_assets_before = AssetHubWestend::execute_with(|| {
type Assets = <AssetHubWestend as AssetHubWestendPallet>::Assets;
<Assets as Inspect<_>>::balance(ASSET_ID, &AssetHubWestendSender::get())
});
let receiver_assets_before = PenpalB::execute_with(|| {
type Assets = <PenpalB as PenpalBPallet>::Assets;
<Assets as Inspect<_>>::balance(ASSET_ID, &PenpalBReceiver::get())
});
test.set_assertion::<AssetHubWestend>(system_para_to_para_assets_sender_assertions);
test.set_assertion::<PenpalB>(system_para_to_para_assets_receiver_assertions);
test.set_dispatchable::<AssetHubWestend>(system_para_to_para_limited_reserve_transfer_assets);
test.assert();
let sender_balance_after = test.sender.balance;
let receiver_balance_after = test.receiver.balance;
// Sender's balance is reduced
assert!(sender_balance_after < sender_balance_before);
// Receiver's balance is increased
assert!(receiver_balance_after > receiver_balance_before);
// Receiver's balance increased by `amount_to_send - delivery_fees - bought_execution`;
// `delivery_fees` might be paid from transfer or JIT, also `bought_execution` is unknown but
// should be non-zero
assert!(receiver_balance_after < receiver_balance_before + fee_amount_to_send);
let sender_assets_after = AssetHubWestend::execute_with(|| {
type Assets = <AssetHubWestend as AssetHubWestendPallet>::Assets;
<Assets as Inspect<_>>::balance(ASSET_ID, &AssetHubWestendSender::get())
});
let receiver_assets_after = PenpalB::execute_with(|| {
type Assets = <PenpalB as PenpalBPallet>::Assets;
<Assets as Inspect<_>>::balance(ASSET_ID, &PenpalBReceiver::get())
});
// Sender's balance is reduced by exact amount
assert_eq!(sender_assets_before - asset_amount_to_send, sender_assets_after);
// Receiver's balance is increased by exact amount
assert_eq!(receiver_assets_after, receiver_assets_before + asset_amount_to_send);
} }
@@ -33,7 +33,7 @@ fn send_transact_as_superuser_from_relay_to_system_para_works() {
#[test] #[test]
fn send_xcm_from_para_to_system_para_paying_fee_with_assets_works() { fn send_xcm_from_para_to_system_para_paying_fee_with_assets_works() {
let para_sovereign_account = AssetHubWestend::sovereign_account_id_of( let para_sovereign_account = AssetHubWestend::sovereign_account_id_of(
AssetHubWestend::sibling_location_of(PenpalA::para_id()), AssetHubWestend::sibling_location_of(PenpalB::para_id()),
); );
// Force create and mint assets for Parachain's sovereign account // Force create and mint assets for Parachain's sovereign account
@@ -60,8 +60,8 @@ fn send_xcm_from_para_to_system_para_paying_fee_with_assets_works() {
let native_asset = let native_asset =
(X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), fee_amount).into(); (X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), fee_amount).into();
let root_origin = <PenpalA as Chain>::RuntimeOrigin::root(); let root_origin = <PenpalB as Chain>::RuntimeOrigin::root();
let system_para_destination = PenpalA::sibling_location_of(AssetHubWestend::para_id()).into(); let system_para_destination = PenpalB::sibling_location_of(AssetHubWestend::para_id()).into();
let xcm = xcm_transact_paid_execution( let xcm = xcm_transact_paid_execution(
call, call,
origin_kind, origin_kind,
@@ -69,14 +69,14 @@ fn send_xcm_from_para_to_system_para_paying_fee_with_assets_works() {
para_sovereign_account.clone(), para_sovereign_account.clone(),
); );
PenpalA::execute_with(|| { PenpalB::execute_with(|| {
assert_ok!(<PenpalA as PenpalAPallet>::PolkadotXcm::send( assert_ok!(<PenpalB as PenpalBPallet>::PolkadotXcm::send(
root_origin, root_origin,
bx!(system_para_destination), bx!(system_para_destination),
bx!(xcm), bx!(xcm),
)); ));
PenpalA::assert_xcm_pallet_sent(); PenpalB::assert_xcm_pallet_sent();
}); });
AssetHubWestend::execute_with(|| { AssetHubWestend::execute_with(|| {
@@ -114,7 +114,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
let foreign_asset1_at_asset_hub_westend = Box::new(MultiLocation { let foreign_asset1_at_asset_hub_westend = Box::new(MultiLocation {
parents: 1, parents: 1,
interior: X3( interior: X3(
Parachain(PenpalA::para_id().into()), Parachain(PenpalB::para_id().into()),
PalletInstance(ASSETS_PALLET_ID), PalletInstance(ASSETS_PALLET_ID),
GeneralIndex(ASSET_ID.into()), GeneralIndex(ASSET_ID.into()),
), ),
@@ -125,18 +125,18 @@ fn swap_locally_on_chain_using_foreign_assets() {
.into(); .into();
let penpal_location = let penpal_location =
MultiLocation { parents: 1, interior: X1(Parachain(PenpalA::para_id().into())) }; MultiLocation { parents: 1, interior: X1(Parachain(PenpalB::para_id().into())) };
// 1. Create asset on penpal: // 1. Create asset on penpal:
PenpalA::execute_with(|| { PenpalB::execute_with(|| {
assert_ok!(<PenpalA as PenpalAPallet>::Assets::create( assert_ok!(<PenpalB as PenpalBPallet>::Assets::create(
<PenpalA as Chain>::RuntimeOrigin::signed(PenpalASender::get()), <PenpalB as Chain>::RuntimeOrigin::signed(PenpalBSender::get()),
ASSET_ID.into(), ASSET_ID.into(),
PenpalASender::get().into(), PenpalBSender::get().into(),
1000, 1000,
)); ));
assert!(<PenpalA as PenpalAPallet>::Assets::asset_exists(ASSET_ID)); assert!(<PenpalB as PenpalBPallet>::Assets::asset_exists(ASSET_ID));
}); });
// 2. Create foreign asset on asset_hub_westend: // 2. Create foreign asset on asset_hub_westend:
@@ -190,18 +190,18 @@ fn swap_locally_on_chain_using_foreign_assets() {
])); ]));
// Send XCM message from penpal => asset_hub_westend // Send XCM message from penpal => asset_hub_westend
let sudo_penpal_origin = <PenpalA as Chain>::RuntimeOrigin::root(); let sudo_penpal_origin = <PenpalB as Chain>::RuntimeOrigin::root();
PenpalA::execute_with(|| { PenpalB::execute_with(|| {
assert_ok!(<PenpalA as PenpalAPallet>::PolkadotXcm::send( assert_ok!(<PenpalB as PenpalBPallet>::PolkadotXcm::send(
sudo_penpal_origin.clone(), sudo_penpal_origin.clone(),
bx!(assets_para_destination.clone()), bx!(assets_para_destination.clone()),
bx!(xcm), bx!(xcm),
)); ));
type RuntimeEvent = <PenpalA as Chain>::RuntimeEvent; type RuntimeEvent = <PenpalB as Chain>::RuntimeEvent;
assert_expected_events!( assert_expected_events!(
PenpalA, PenpalB,
vec![ vec![
RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {}, RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {},
] ]
@@ -157,10 +157,12 @@ fn system_para_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult {
fn limited_teleport_native_assets_from_relay_to_system_para_works() { fn limited_teleport_native_assets_from_relay_to_system_para_works() {
// Init values for Relay Chain // Init values for Relay Chain
let amount_to_send: Balance = WESTEND_ED * 1000; let amount_to_send: Balance = WESTEND_ED * 1000;
let dest = Westend::child_location_of(AssetHubWestend::para_id());
let beneficiary = AssetHubWestendReceiver::get();
let test_args = TestContext { let test_args = TestContext {
sender: WestendSender::get(), sender: WestendSender::get(),
receiver: AssetHubWestendReceiver::get(), receiver: beneficiary.clone(),
args: relay_test_args(amount_to_send), args: relay_test_args(dest, beneficiary, amount_to_send),
}; };
let mut test = RelayToSystemParaTest::new(test_args); let mut test = RelayToSystemParaTest::new(test_args);
@@ -204,7 +206,7 @@ fn limited_teleport_native_assets_back_from_system_para_to_relay_works() {
let test_args = TestContext { let test_args = TestContext {
sender: AssetHubWestendSender::get(), sender: AssetHubWestendSender::get(),
receiver: WestendReceiver::get(), receiver: WestendReceiver::get(),
args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), args: para_test_args(destination, beneficiary_id, amount_to_send, assets, None, 0),
}; };
let mut test = SystemParaToRelayTest::new(test_args); let mut test = SystemParaToRelayTest::new(test_args);
@@ -245,7 +247,7 @@ fn limited_teleport_native_assets_from_system_para_to_relay_fails() {
let test_args = TestContext { let test_args = TestContext {
sender: AssetHubWestendSender::get(), sender: AssetHubWestendSender::get(),
receiver: WestendReceiver::get(), receiver: WestendReceiver::get(),
args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), args: para_test_args(destination, beneficiary_id, amount_to_send, assets, None, 0),
}; };
let mut test = SystemParaToRelayTest::new(test_args); let mut test = SystemParaToRelayTest::new(test_args);
@@ -278,10 +280,12 @@ fn limited_teleport_native_assets_from_system_para_to_relay_fails() {
fn teleport_native_assets_from_relay_to_system_para_works() { fn teleport_native_assets_from_relay_to_system_para_works() {
// Init values for Relay Chain // Init values for Relay Chain
let amount_to_send: Balance = WESTEND_ED * 1000; let amount_to_send: Balance = WESTEND_ED * 1000;
let dest = Westend::child_location_of(AssetHubWestend::para_id());
let beneficiary = AssetHubWestendReceiver::get();
let test_args = TestContext { let test_args = TestContext {
sender: WestendSender::get(), sender: WestendSender::get(),
receiver: AssetHubWestendReceiver::get(), receiver: beneficiary.clone(),
args: relay_test_args(amount_to_send), args: relay_test_args(dest, beneficiary, amount_to_send),
}; };
let mut test = RelayToSystemParaTest::new(test_args); let mut test = RelayToSystemParaTest::new(test_args);
@@ -325,7 +329,7 @@ fn teleport_native_assets_back_from_system_para_to_relay_works() {
let test_args = TestContext { let test_args = TestContext {
sender: AssetHubWestendSender::get(), sender: AssetHubWestendSender::get(),
receiver: WestendReceiver::get(), receiver: WestendReceiver::get(),
args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), args: para_test_args(destination, beneficiary_id, amount_to_send, assets, None, 0),
}; };
let mut test = SystemParaToRelayTest::new(test_args); let mut test = SystemParaToRelayTest::new(test_args);
@@ -366,7 +370,7 @@ fn teleport_native_assets_from_system_para_to_relay_fails() {
let test_args = TestContext { let test_args = TestContext {
sender: AssetHubWestendSender::get(), sender: AssetHubWestendSender::get(),
receiver: WestendReceiver::get(), receiver: WestendReceiver::get(),
args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None), args: para_test_args(destination, beneficiary_id, amount_to_send, assets, None, 0),
}; };
let mut test = SystemParaToRelayTest::new(test_args); let mut test = SystemParaToRelayTest::new(test_args);
@@ -394,16 +398,15 @@ fn teleport_native_assets_from_system_para_to_relay_fails() {
assert_eq!(receiver_balance_after, receiver_balance_before); assert_eq!(receiver_balance_after, receiver_balance_before);
} }
// TODO: uncomment when CollectivesWestend and BridgeHubWestend are implemented #[test]
// https://github.com/paritytech/polkadot-sdk/pull/1737 (CollectivesWestend) fn teleport_to_other_system_parachains_works() {
// #[test] let amount = ASSET_HUB_WESTEND_ED * 100;
// fn teleport_to_other_system_parachains_works() { let native_asset: MultiAssets = (Parent, amount).into();
// let amount = ASSET_HUB_WESTEND_ED * 100;
// let native_asset: VersionedMultiAssets = (Parent, amount).into();
// test_parachain_is_trusted_teleporter!( test_parachain_is_trusted_teleporter!(
// AssetHubWestend, // Origin AssetHubWestend, // Origin
// vec![CollectivesWestend, BridgeHubWestend], // Destinations AssetHubWestendXcmConfig, // XCM Configuration
// (native_asset, amount) vec![BridgeHubWestend], // Destinations
// ); (native_asset, amount)
// } );
}