From e8420e43969621d62b1650f26419a71a9f779d5a Mon Sep 17 00:00:00 2001 From: Frank Bell Date: Wed, 9 Nov 2022 09:45:22 +0000 Subject: [PATCH] test: add asset teleport/reserve-transfer tests --- integration-tests/README.md | 5 +- .../config.toml | 0 .../0_reserve_transfer.yml | 429 ++++++++++++++++++ .../1_reserve_transfer_two_hops.yml | 338 ++++++++++++++ .../teleport-asset/0_teleport.yml | 353 ++++++++++++++ 5 files changed, 1124 insertions(+), 1 deletion(-) rename xcm-playground.toml => integration-tests/config.toml (100%) create mode 100644 integration-tests/reserve-transfer-asset/0_reserve_transfer.yml create mode 100644 integration-tests/reserve-transfer-asset/1_reserve_transfer_two_hops.yml create mode 100644 integration-tests/teleport-asset/0_teleport.yml diff --git a/integration-tests/README.md b/integration-tests/README.md index 2fbdf666..e3b11ef8 100644 --- a/integration-tests/README.md +++ b/integration-tests/README.md @@ -15,5 +15,8 @@ Please refer to the [project's `README.md`](https://github.com/paritytech/parach For example, to use zombienet and perform a reserve transfer that tests the functionality of `asset-registry` pallet: ``` -$ parachains-integration-tests -m zombienet-test -c xcm-playground.toml -t integration-tests/asset-registry/0_reserve_transfer.yml +$ parachains-integration-tests -m zombienet-test -c integration-tests/config.toml -t integration-tests/asset-registry/0_reserve_transfer.yml + +$ parachains-integration-tests -m zombienet-test -c integration-tests/config.toml -t integration-tests/teleport-asset +$ parachains-integration-tests -m zombienet-test -c integration-tests/config.toml -t integration-tests/reserve-transfer-asset ``` diff --git a/xcm-playground.toml b/integration-tests/config.toml similarity index 100% rename from xcm-playground.toml rename to integration-tests/config.toml diff --git a/integration-tests/reserve-transfer-asset/0_reserve_transfer.yml b/integration-tests/reserve-transfer-asset/0_reserve_transfer.yml new file mode 100644 index 00000000..5ae74ec5 --- /dev/null +++ b/integration-tests/reserve-transfer-asset/0_reserve_transfer.yml @@ -0,0 +1,429 @@ +--- +settings: + chains: + relay_chain: &relay_chain + wsPort: 9900 + reserve_parachain: &reserve_parachain + wsPort: 9910 + paraId: &rp_id 1000 + trappist_parachain: &trappist_parachain + wsPort: 9920 + paraId: &tp_id 2000 + variables: + common: + asset_decimals: &asset_decimals 12 + chains: + relay_chain: + signer: &rc_signer //Alice + reserve_parachain: + signer: &rp_signer //Alice + assets_pallet: &rp_assets_pallet_id 50 + asset: + id: &rp_asset_id 1 + owner: &rp_asset_owner HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F # Alice + min_balance: &rp_asset_min_balance 1000000000 + name: &rp_asset_name xUSD + symbol: &rp_asset_symbol xUSD + mint_amount: &rp_mint_amount 1000000000000000000 + mint_amount_string: &rp_mint_amount_string '1000000000000000000' # Workaround: string required when value > Number.MAX_SAFE_INTEGER + beneficiary: &rp_asset_beneficiary FoQJpPyadYccjavVdTWxpxU7rUEaYhfLCPwXgkfD6Zat9QP # Bob + max_individual: &rp_dmp_max_individual 10000000000 + transfer_amount: &rp_transfer_amount 10000000000000000 # 10,000,000,000,000,000 + transfer_amount_string: &rp_transfer_amount_string '10000000000000000' # 10,000,000,000,000,000 + beneficiary: &rp_asset_signer //Bob + trappist_parachain_sovereign_account: &tp_sovereign_account FBeL7EAeUroLWXW1yfKboiqTqVfbRBcsUKd6QqVf4kGBySS + trappist_parachain: + signer: &tp_signer //Alice + derivative_asset: + id: &tp_asset_id 10 + owner: &tp_asset_owner 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice + min_balance: &tp_asset_min_balance 1000000000 + name: &tp_asset_name txUSD + symbol: &tp_asset_symbol txUSD + beneficiary_account: &tp_beneficiary_account 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty # Bob + beneficiary_account_key: &tp_beneficiary_account_key '0x8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48' # Bob + decodedCalls: + force_asset_status: + chain: *reserve_parachain + pallet: assets + call: forceAssetStatus + args: [ + *rp_asset_id, # id + { id: *rp_asset_owner }, # owner + { id: *rp_asset_owner }, # issuer + { id: *rp_asset_owner }, # admin + { id: *rp_asset_owner }, # freezer + *rp_asset_min_balance, # minBalance + true, # isSufficient + false, # isFrozen + ] + +tests: + - name: HRMP + describes: + - name: polkadotXcm.limitedReserveTransferAssets | Reserve Parachain -> Trappist Parachain + before: + - name: Create fungible asset on Reserve Parachain + actions: + - extrinsics: + # Create asset + - chain: *reserve_parachain + signer: *rp_signer + pallet: assets + call: create + delay: 0 + args: [ + *rp_asset_id, # id + { id: *rp_asset_owner }, # owner + *rp_asset_min_balance # min balance + ] + events: + - chain: *reserve_parachain + name: assets.Created + attributes: + - key: assetId + value: *rp_asset_id + - key: creator + value: *rp_asset_owner + - key: owner + value: *rp_asset_owner + # Set metadata + - chain: *reserve_parachain + signer: *rp_signer + pallet: assets + call: setMetadata + args: [ + *rp_asset_id, # id + *rp_asset_name, # name + *rp_asset_symbol, # symbol + *asset_decimals # decimals + ] + events: + - chain: *reserve_parachain + name: assets.MetadataSet + attributes: + - key: assetId + value: *rp_asset_id + - key: name + value: *rp_asset_name + - key: symbol + value: *rp_asset_symbol + - key: decimals + value: *asset_decimals + + - name: Mint fungible asset and check balances + actions: + - extrinsics: + - chain: *reserve_parachain + signer: *rp_signer + pallet: assets + call: mint + delay: 0 + args: [ + *rp_asset_id, # id + { id: *rp_asset_beneficiary }, # beneficiary + *rp_mint_amount_string, # amount + ] + events: + - chain: *reserve_parachain + name: assets.Issued + attributes: + - key: assetId + value: *rp_asset_id + - key: owner + value: *rp_asset_beneficiary + - key: totalSupply + type: u128 + value: *rp_mint_amount + - queries: + beneficiary_asset_balance: + chain: *reserve_parachain + pallet: assets + call: account + delay: 0 + args: [ *rp_asset_id, *rp_asset_beneficiary ] + selector: 'value.balance' + - asserts: + equal: + args: [ $beneficiary_asset_balance, *rp_mint_amount ] + + - name: Declare xUSD (on Reserve Parachain) as self-sufficient via Relay Chain + actions: + - extrinsics: + - chain: *relay_chain + sudo: true + signer: *rc_signer + pallet: parasSudoWrapper + call: sudoQueueDownwardXcm + delay: 0 + args: [ + *rp_id, # id + { + v2: [ + { + Transact: { + originType: Superuser, + requireWeightAtMost: *rp_dmp_max_individual, + call: $force_asset_status + } + } + ] + }, # xcm + ] + events: + - chain: *relay_chain + name: sudo.Sudid + attributes: + - key: sudoResult + value: Ok + - chain: *reserve_parachain + name: assets.AssetStatusChanged + attributes: + - key: assetId + value: *rp_asset_id + - queries: + is_sufficient: + chain: *reserve_parachain + pallet: assets + call: asset + delay: 0 + args: [ *rp_asset_id ] + selector: 'value.isSufficient' + - asserts: + equal: + args: [ $is_sufficient, true ] + + - name: Create derivative asset on Trappist Parachain + actions: + - extrinsics: + # Create asset + - chain: *trappist_parachain + signer: *tp_signer + pallet: assets + call: create + delay: 0 + args: [ + *tp_asset_id, # id + { id: *tp_asset_owner }, # owner + *tp_asset_min_balance # min balance + ] + events: + - chain: *trappist_parachain + name: assets.Created + attributes: + - key: assetId + value: *tp_asset_id + - key: creator + value: *tp_asset_owner + - key: owner + value: *tp_asset_owner + # Set metadata + - chain: *trappist_parachain + signer: *tp_signer + pallet: assets + call: setMetadata + args: [ + *tp_asset_id, # id + *tp_asset_name, # name + *tp_asset_symbol, # symbol + *asset_decimals # decimals + ] + events: + - chain: *trappist_parachain + name: assets.MetadataSet + attributes: + - key: assetId + value: *tp_asset_id + - key: name + value: *tp_asset_name + - key: symbol + value: *tp_asset_symbol + - key: decimals + value: *asset_decimals + # todo: set as sufficient once removed from chain spec + + - name: Map derivative asset (txUSD) to multi-location (xUSD within Assets pallet on Reserve Parachain) via Asset Registry + actions: + - extrinsics: + - chain: *trappist_parachain + sudo: true + signer: *tp_signer + pallet: assetRegistry + call: registerReserveAsset + delay: 0 + args: [ + *tp_asset_id, # asset id + { + parents: 1, + interior: { + X3: [ + { + Parachain: *rp_id + }, + { + PalletInstance: *rp_assets_pallet_id + }, + { + GeneralIndex: *rp_asset_id + } + ] + } + } # asset multi-location + ] + events: + - chain: *trappist_parachain + name: sudo.Sudid + attributes: + - key: sudoResult + value: Ok + - chain: *trappist_parachain + name: assetRegistry.ReserveAssetRegistered + attributes: + - key: assetId + value: *tp_asset_id + - queries: + asset_registered: + chain: *trappist_parachain + pallet: assetRegistry + call: assetIdMultiLocation + delay: 0 + args: [ *tp_asset_id ] + - asserts: + isSome: + args: [ $asset_registered ] + + its: + - name: Reserve parachain should be able to reserve-transfer an asset to Trappist Parachain + actions: + - extrinsics: + - chain: *reserve_parachain + signer: *rp_asset_signer + pallet: polkadotXcm + call: limitedReserveTransferAssets + args: [ + # dest: XcmVersionedMultiLocation + { + v1: { + parents: 1, + interior: { + x1: { + Parachain: *tp_id + } + } + } + }, + # beneficiary: XcmVersionedMultiLocation + { + v1: { + parents: 0, + interior: { + x1: { + AccountId32: { + network: Any, + id: *tp_beneficiary_account_key + } + } + } + } + }, + # assets: XcmVersionedMultiAssets + { + v1: [ + { + id: { + Concrete: { + parents: 0, + interior: { + x2: [ + { + PalletInstance: *rp_assets_pallet_id + }, + { + GeneralIndex: *rp_asset_id + } + ] + } + } + }, + fun: { + Fungible: *rp_transfer_amount_string + } + } + ] + }, + # feeAssetItem: u32 + 0, + # weightLimit: XcmV2WeightLimit + Unlimited + ] + events: + # XCM message attempted + - chain: *reserve_parachain + name: polkadotXcm.Attempted + attributes: + - type: XcmV2TraitsOutcome + xcmOutcome: Complete + threshold: [ 10, 10 ] + value: 654,608,000 + # Amount transferred from sender to sovereign account + - chain: *reserve_parachain + name: assets.Transferred + attributes: + - key: assetId + value: *rp_asset_id + - key: from + value: *rp_asset_beneficiary + - key: to + value: *tp_sovereign_account + - key: amount + value: *rp_transfer_amount + # Sovereign account created + - chain: *reserve_parachain + name: system.NewAccount + attributes: + - type: AccountId32 + value: *tp_sovereign_account + # XCM message queued on HRMP channel + - chain: *reserve_parachain + name: xcmpQueue.XcmpMessageSent + # XCM message executed successfully + - chain: *trappist_parachain + name: xcmpQueue.Success + # Derivative assets issued to beneficiary on Trappist chain + - chain: *trappist_parachain + name: assets.Issued + attributes: + - key: assetId + value: *tp_asset_id + - key: owner + value: *tp_beneficiary_account + - key: totalSupply + value: *rp_transfer_amount + threshold: [ 10, 0 ] # less fees + - queries: + sovereign_account_balance: + chain: *reserve_parachain + pallet: assets + call: account + delay: 0 + args: [ *rp_asset_id, *tp_sovereign_account ] + selector: 'value.balance' + beneficiary_account: + chain: *trappist_parachain + pallet: assets + call: account + delay: 0 + args: [ *tp_asset_id, *tp_beneficiary_account ] + - asserts: + equal: + args: [ $sovereign_account_balance, *rp_transfer_amount ] + assetsIncreased: + args: [ + { + balances: { + amount: *rp_transfer_amount, + fees: 1600000000, + after: $beneficiary_account, + } + } + ] \ No newline at end of file diff --git a/integration-tests/reserve-transfer-asset/1_reserve_transfer_two_hops.yml b/integration-tests/reserve-transfer-asset/1_reserve_transfer_two_hops.yml new file mode 100644 index 00000000..4b39da3c --- /dev/null +++ b/integration-tests/reserve-transfer-asset/1_reserve_transfer_two_hops.yml @@ -0,0 +1,338 @@ +--- +settings: + chains: + relay_chain: &relay_chain + wsPort: 9900 + reserve_parachain: &reserve_parachain + wsPort: 9910 + paraId: &rp_id 1000 + trappist_parachain: &trappist_parachain + wsPort: 9920 + paraId: 2000 + tertiary_parachain: &tertiary_parachain + wsPort: 9930 + paraId: &3p_id 3000 + variables: + common: + asset_decimals: &asset_decimals 12 + chains: + relay_chain: + signer: &rc_signer //Alice + reserve_parachain: + assets_pallet: &rp_assets_pallet_id 50 + asset: + id: &rp_asset_id 1 + max_individual: &rp_dmp_max_individual 10000000000 + trappist_parachain_sovereign_account: &tp_sovereign_account FBeL7EAeUroLWXW1yfKboiqTqVfbRBcsUKd6QqVf4kGBySS + tertiary_parachain_sovereign_account: &3p_sovereign_account FBeL7E5qk5Jt7ZHCNrMj5WyEC5Tpm7eoisxW9k14zPJr99B + trappist_parachain: + sender: &tp_sender //Bob + derivative_asset: + id: &tp_asset_id 10 + transfer_amount: &tp_transfer_amount 1000000000000000 # 1,000,000,000,000,000 + beneficiary_account: &tp_beneficiary_account 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty # Bob + execution_cost: &tp_execution_cost 100000000000000 + max_weight: &tp_max_weight 100000000000 + tertiary_parachain: + signer: &3p_signer //Alice + derivative_asset: + id: &3p_asset_id 1 + owner: &3p_asset_owner 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice + min_balance: &3p_asset_min_balance 1000000000 + name: &3p_asset_name pxUSD + symbol: &3p_asset_symbol pxUSD + beneficiary_account: &3p_beneficiary_account 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty # Bob + beneficiary_account_key: &3p_beneficiary_account_key '0x8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48' # Bob + decodedCalls: + update_weight_restrict_decay: + chain: *reserve_parachain + pallet: xcmpQueue + call: updateWeightRestrictDecay + args: [ 0 ] + +tests: + - name: HRMP + describes: + - name: polkadotXcm.limitedReserveTransferAssets | Trappist Parachain -> Tertiary Parachain + before: + # Hack to enable processing of large xcm message + - name: Update XCMP queue config (on Reserve Parachain) via Relay Chain + actions: + - extrinsics: + - chain: *relay_chain + sudo: true + signer: *rc_signer + pallet: parasSudoWrapper + call: sudoQueueDownwardXcm + delay: 0 + args: [ + *rp_id, # id + { + v2: [ + { + Transact: { + originType: Superuser, + requireWeightAtMost: *rp_dmp_max_individual, + call: $update_weight_restrict_decay + } + } + ] + }, # xcm + ] + events: + - chain: *relay_chain + name: sudo.Sudid + attributes: + - key: sudoResult + value: Ok + - chain: *reserve_parachain + name: parachainSystem.DownwardMessagesReceived + - chain: *reserve_parachain + name: parachainSystem.DownwardMessagesProcessed + - chain: *reserve_parachain + name: dmpQueue.ExecutedDownward + attributes: + - type: XcmV2TraitsOutcome + xcmOutcome: Complete + threshold: [ 10, 10 ] + value: 10,021,258,000 + - queries: + weight_restrict_decay: + chain: *reserve_parachain + pallet: xcmpQueue + call: queueConfig + delay: 0 + args: [] + selector: 'weightRestrictDecay' + - asserts: + equal: + args: [ $weight_restrict_decay, { refTime: 0 } ] + + - name: Create fungible asset on Tertiary Parachain + actions: + - extrinsics: + # Create asset + - chain: *tertiary_parachain + signer: *3p_signer + pallet: assets + call: create + delay: 0 + args: [ + *3p_asset_id, # id + { id: *3p_asset_owner }, # owner + *3p_asset_min_balance # min balance + ] + events: + - chain: *tertiary_parachain + name: assets.Created + attributes: + - key: assetId + value: *3p_asset_id + - key: creator + value: *3p_asset_owner + - key: owner + value: *3p_asset_owner + # Set metadata + - chain: *tertiary_parachain + signer: *3p_signer + pallet: assets + call: setMetadata + args: [ + *3p_asset_id, # id + *3p_asset_name, # name + *3p_asset_symbol, # symbol + *asset_decimals # decimals + ] + events: + - chain: *tertiary_parachain + name: assets.MetadataSet + attributes: + - key: assetId + value: *3p_asset_id + - key: name + value: *3p_asset_name + - key: symbol + value: *3p_asset_symbol + - key: decimals + value: *asset_decimals + + its: + - name: Trappist parachain should be able to reserve-transfer an asset to Tertiary Parachain + actions: + - extrinsics: + - chain: *trappist_parachain + signer: *tp_sender + pallet: polkadotXcm + call: execute + args: [ + # message: XcmVersionedXcm + { + V2: [ + { + WithdrawAsset: [ + { + id: { + Concrete: { + parents: 1, + interior: { + X3: [ + { Parachain: *rp_id }, + { PalletInstance: *rp_assets_pallet_id }, + { GeneralIndex: *rp_asset_id } + ] + } + } + }, + fun: { Fungible: *tp_transfer_amount} + } + ] + }, + { + InitiateReserveWithdraw: { + assets: { Wild: All }, + reserve: { parents: 1, interior: { X1: { Parachain: *rp_id } } }, + xcm: [ + { + BuyExecution: { + fees: { + id: { + Concrete: { + parents: 0, + interior: { + X2: [ + { PalletInstance: *rp_assets_pallet_id }, + { GeneralIndex: *rp_asset_id } + ] + } + } + }, + fun: { Fungible: *tp_execution_cost } + }, + weightLimit: Unlimited + } + }, + { + DepositReserveAsset: { + assets: { Wild: All }, + maxAssets: 1, + dest: { + parents: 1, + interior: { + X1: { Parachain: *3p_id } + } + }, + xcm: [ + { + DepositAsset: { + assets: { Wild: All }, + maxAssets: 1, + beneficiary: { + parents: 0, + interior: { + X1: { AccountId32: { network: Any, id: *3p_beneficiary_account_key } } + } + } + } + } + ] + } + } + ] + } + } + ] + }, + # maxWeight: Weight + { refTime: *tp_max_weight } + ] + events: + # XCM message attempted + - chain: *trappist_parachain + name: polkadotXcm.Attempted + attributes: + - type: XcmV2TraitsOutcome + xcmOutcome: Complete + threshold: [ 10, 10 ] + value: 2,000,000,000 + # Amount transferred burned from sender account (derivative asset) + - chain: *trappist_parachain + name: assets.Burned + attributes: + - key: assetId + value: *tp_asset_id + - key: owner + value: *tp_beneficiary_account + - key: balance + value: *tp_transfer_amount + # Amount transferred burned from sender account (real asset) + - chain: *reserve_parachain + name: assets.Burned + attributes: + - key: assetId + value: *rp_asset_id + - key: owner + value: *tp_sovereign_account + - key: balance + value: *tp_transfer_amount + # Amount issued to sovereign account of tertiary parachain + - chain: *reserve_parachain + name: assets.Issued + attributes: + - key: assetId + value: *rp_asset_id + - key: owner + value: *3p_sovereign_account + - key: totalSupply + threshold: [ 10, 0 ] # less fees + value: *tp_transfer_amount + # HRMP message sent to sibling parachain + - chain: *reserve_parachain + name: xcmpQueue.XcmpMessageSent + # Amount issued to sovereign account of tertiary parachain + - chain: *tertiary_parachain + name: assets.Issued + attributes: + - key: assetId + value: *3p_asset_id + - key: owner + value: *3p_beneficiary_account + - key: totalSupply + threshold: [ 10, 0 ] # less fees + value: *tp_transfer_amount + # Amount issued to sovereign account of tertiary parachain + - chain: *tertiary_parachain + name: xcmpQueue.Success + - queries: + sovereign_account_balance: + chain: *reserve_parachain + pallet: assets + call: account + delay: 0 + args: [ *rp_asset_id, *3p_sovereign_account ] + beneficiary_account: + chain: *tertiary_parachain + pallet: assets + call: account + delay: 0 + args: [ *3p_asset_id, *3p_beneficiary_account ] + - asserts: + - assetsIncreased: + args: [ + { + balances: { + amount: *tp_transfer_amount, + fees: 65000000000, + after: $sovereign_account_balance, + } + } + ] + - assetsIncreased: + args: [ + { + balances: { + amount: *tp_transfer_amount, + fees: 65000000000, + after: $beneficiary_account, + } + } + ] \ No newline at end of file diff --git a/integration-tests/teleport-asset/0_teleport.yml b/integration-tests/teleport-asset/0_teleport.yml new file mode 100644 index 00000000..bb743783 --- /dev/null +++ b/integration-tests/teleport-asset/0_teleport.yml @@ -0,0 +1,353 @@ +--- +settings: + chains: + relay_chain: &relay_chain + wsPort: 9900 + reserve_parachain: &reserve_parachain + wsPort: 9910 + paraId: &rp_id 1000 + variables: + common: + teleport: + amount_dmp: &dmp_teleport_amount 1000000000000000 # 1,000,000,000,000,000 + amount_ump: &ump_teleport_amount 500000000000000 # 500,000,000,000,000 + chains: + relay_chain: + signer: &rc_signer //Alice + sender_account: &rc_sender_account 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY + teleport_account: &rc_teleport_account 5EYCAe5ijiYgWYWi1fs8Xz1td1djEtJVVnNfzvDRP4VtLL7Y + receiver_account: &rc_receiver_account 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty # Bob + receiver_account_key: &rc_receiver_account_key '0x8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48' + reserve_parachain: + signer: &rp_signer //Bob + account: &rp_receiver_account FoQJpPyadYccjavVdTWxpxU7rUEaYhfLCPwXgkfD6Zat9QP + account_key: &rp_receiver_account_key '0x8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48' + decodedCalls: {} + +tests: + - name: DMP + describes: + - name: xcmPallet.limitedTeleportAssets | Relay Chain -> Reserve Parachain + before: + - name: Get the balances of the Relay Chain's sender & Reserve Parachain's receiver + actions: + - queries: + relay_chain_sender_balance_before: + chain: *relay_chain + pallet: system + call: account + delay: 0 + args: [ *rc_sender_account ] + reserve_chain_receiver_balance_before: + chain: *reserve_parachain + pallet: system + call: account + delay: 0 + args: [ *rp_receiver_account ] + reserve_chain_total_issuance_before: + chain: *reserve_parachain + pallet: balances + call: totalIssuance + delay: 0 + args: [] + + its: + - name: Relay chain should be able to teleport an asset to Reserve Parachain + actions: + - extrinsics: + - chain: *relay_chain + signer: *rc_signer + pallet: xcmPallet + call: limitedTeleportAssets + args: [ + # dest: XcmVersionedMultiLocation + { v1: { parents: 0, interior: { x1: { Parachain: *rp_id } } } }, + # beneficiary: XcmVersionedMultiLocation + { + v1: { + parents: 0, + interior: { x1: { AccountId32: { network: Any, id: *rp_receiver_account_key } } } + } + }, + # assets: XcmVersionedMultiAssets + { + v1: [ + { + id: { Concrete: { parents: 0, interior: Here } }, + fun: { Fungible: *dmp_teleport_amount } + } + ] + }, + # feeAssetItem: u32 + 0, + # weightLimit: XcmV2WeightLimit + Unlimited + ] + events: + # XCM message attempted + - chain: *relay_chain + name: xcmPallet.Attempted + attributes: + - type: XcmV2TraitsOutcome + xcmOutcome: Complete + threshold: [ 10, 10 ] + value: 761,173,000 + # Teleport amount withdrawn from sender's account (on relay chain) + - chain: *relay_chain + name: balances.Withdraw + attributes: + - type: AccountId32 + value: *rc_sender_account + - type: u128 + value: *dmp_teleport_amount + # Fees deducted from sender's account for the teleport (on relay chain) + - chain: *relay_chain + name: balances.Withdraw + attributes: + - type: AccountId32 + value: *rc_sender_account + - type: u128 + threshold: [10, 10] + value: 148,804,953 + # Teleport checking account created + - chain: *relay_chain + name: system.NewAccount + attributes: + - type: AccountId32 + value: *rc_teleport_account + # Teleport checking account endowed with balance + - chain: *relay_chain + name: balances.Endowed + attributes: + - type: AccountId32 + value: *rc_teleport_account + - type: u128 + value: *dmp_teleport_amount + # Amount deposited into teleport checking account + - chain: *relay_chain + name: balances.Deposit + attributes: + - type: AccountId32 + value: *rc_teleport_account + - type: u128 + value: *dmp_teleport_amount + + # XCM message(s) received on reserve parachain + - chain: *reserve_parachain + name: parachainSystem.DownwardMessagesReceived + # XCM message executed on reserve parachain + - chain: *reserve_parachain + name: dmpQueue.ExecutedDownward + # Teleported amount deposited into receiver account (less fees) + - chain: *reserve_parachain + name: balances.Deposit + attributes: + - type: AccountId32 + value: *rp_receiver_account + - type: u128 + threshold: [10, 0] + value: *dmp_teleport_amount + - queries: + relay_chain_sender_balance: + chain: *relay_chain + pallet: system + call: account + delay: 0 + args: [ *rc_sender_account ] + teleport_account_balance: + chain: *relay_chain + pallet: system + call: account + delay: 0 + args: [ *rc_teleport_account ] + selector: 'data.free' + reserve_chain_receiver_balance: + chain: *reserve_parachain + pallet: system + call: account + delay: 0 + args: [ *rp_receiver_account ] + reserve_chain_total_issuance: + chain: *reserve_parachain + pallet: balances + call: totalIssuance + delay: 0 + args: [] + - asserts: + # Sender's account was decreased by teleported amount + fees + - balanceDecreased: + args: [ + { + amount: *dmp_teleport_amount, + balances: { + before: $relay_chain_sender_balance_before, + after: $relay_chain_sender_balance, + } + } + ] + # Teleport account balance is teleported amount + - equal: + args: [ $teleport_account_balance, *dmp_teleport_amount ] + # Reserve parachain total issuance increased by teleported amount + - valueIncreased: + args: [ + { + before: $reserve_chain_total_issuance_before, + after: $reserve_chain_total_issuance, + } + ] + # Receiver's account increased by teleported amount - fees + - balanceIncreased: + args: [ + { + amount: *dmp_teleport_amount, + fees: 3947456, + balances: { + before: $reserve_chain_receiver_balance_before, + after: $reserve_chain_receiver_balance, + } + } + ] + + - name: UMP + describes: + - name: polkadotXcm.limitedTeleportAssets | Reserve Parachain -> Relay Chain + before: + - name: Get the balances of the Reserve Parachain's sender & total issuance + actions: + - queries: + reserve_chain_sender_balance_before: + chain: *reserve_parachain + pallet: system + call: account + delay: 0 + args: [ *rp_receiver_account ] + reserve_chain_total_issuance_before: + chain: *reserve_parachain + pallet: balances + call: totalIssuance + delay: 0 + args: [] + + its: + - name: Reserve parachain should be able to teleport an asset to Relay Chain + actions: + - extrinsics: + - chain: *reserve_parachain + signer: *rp_signer + pallet: polkadotXcm + call: limitedTeleportAssets + args: [ + # dest: XcmVersionedMultiLocation + { v1: { parents: 1, interior: Here } }, + # beneficiary: XcmVersionedMultiLocation + { + v1: { + parents: 0, + interior: { + x1: { AccountId32: { network: Any, id: *rc_receiver_account_key } } + } + } + }, + # assets: XcmVersionedMultiAssets + { + v1: [ + { + id: { Concrete: { parents: 1, interior: Here } }, + fun: { Fungible: *ump_teleport_amount } + } + ] + }, + # feeAssetItem: u32 + 0, + # weightLimit: XcmV2WeightLimit + Unlimited + ] + events: + # XCM message attempted + - chain: *reserve_parachain + name: polkadotXcm.Attempted + attributes: + - type: XcmV2TraitsOutcome + xcmOutcome: Complete + threshold: [ 10, 10 ] + value: 360,315,000 + # Teleport amount withdrawn from sender's account (on reserve parachain) + - chain: *reserve_parachain + name: balances.Withdraw + attributes: + - type: AccountId32 + value: *rp_receiver_account + - type: u128 + value: *ump_teleport_amount + # Fees deducted from sender's account for the teleport (on reserve parachain) + - chain: *reserve_parachain + name: balances.Withdraw + attributes: + - type: AccountId32 + value: *rp_receiver_account + - type: u128 + threshold: [10, 10] + value: 7,822,644 + + # XCM UMP messages received + - chain: *relay_chain + name: ump.UpwardMessagesReceived + # XCM UMP message executed + - chain: *relay_chain + name: ump.ExecutedUpward + attributes: + - type: XcmV2TraitsOutcome + xcmOutcome: Complete + threshold: [ 10, 10 ] + value: 297,578,000 + # Requested withdrawn from Teleport checking account (on relay chain) + - chain: *relay_chain + name: balances.Withdraw + attributes: + - type: AccountId32 + value: *rc_teleport_account + - type: u128 + value: *ump_teleport_amount + # Amount deposited into receiver's account + - chain: *relay_chain + name: balances.Deposit + attributes: + - type: AccountId32 + value: *rc_receiver_account + - type: u128 + threshold: [ 10, 0 ] + value: *ump_teleport_amount + - queries: + reserve_chain_sender_balance: + chain: *reserve_parachain + pallet: system + call: account + delay: 0 + args: [ *rp_receiver_account ] + reserve_chain_total_issuance: + chain: *reserve_parachain + pallet: balances + call: totalIssuance + delay: 0 + args: [] + - asserts: + # Sender's account was decreased by teleported amount + fees + - balanceDecreased: + args: [ + { + amount: *ump_teleport_amount, + balances: { + before: $reserve_chain_sender_balance_before, + after: $reserve_chain_sender_balance, + } + } + ] + # Reserve parachain total issuance increased by teleported amount + - valueDecreased: + args: [ + { + before: $reserve_chain_total_issuance_before, + after: $reserve_chain_total_issuance, + } + ] \ No newline at end of file