Skip to content

Commit 2cdda0e

Browse files
authored
Bridge zombienet tests: Check amount received at destination (#3490)
Related to #3475
1 parent 94c54d5 commit 2cdda0e

File tree

6 files changed

+27
-22
lines changed

6 files changed

+27
-22
lines changed

bridges/testing/environments/rococo-westend/bridges_rococo_westend.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,50 +319,54 @@ case "$1" in
319319
$XCM_VERSION
320320
;;
321321
reserve-transfer-assets-from-asset-hub-rococo-local)
322+
amount=$2
322323
ensure_polkadot_js_api
323324
# send ROCs to Alice account on AHW
324325
limited_reserve_transfer_assets \
325326
"ws://127.0.0.1:9910" \
326327
"//Alice" \
327328
"$(jq --null-input '{ "V3": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Westend" }, { "Parachain": 1000 } ] } } }')" \
328329
"$(jq --null-input '{ "V3": { "parents": 0, "interior": { "X1": { "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } } } } }')" \
329-
"$(jq --null-input '{ "V3": [ { "id": { "Concrete": { "parents": 1, "interior": "Here" } }, "fun": { "Fungible": 5000000000000 } } ] }')" \
330+
"$(jq --null-input '{ "V3": [ { "id": { "Concrete": { "parents": 1, "interior": "Here" } }, "fun": { "Fungible": '$amount' } } ] }')" \
330331
0 \
331332
"Unlimited"
332333
;;
333334
withdraw-reserve-assets-from-asset-hub-rococo-local)
335+
amount=$2
334336
ensure_polkadot_js_api
335337
# send back only 100000000000 wrappedWNDs to Alice account on AHW
336338
limited_reserve_transfer_assets \
337339
"ws://127.0.0.1:9910" \
338340
"//Alice" \
339341
"$(jq --null-input '{ "V3": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Westend" }, { "Parachain": 1000 } ] } } }')" \
340342
"$(jq --null-input '{ "V3": { "parents": 0, "interior": { "X1": { "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } } } } }')" \
341-
"$(jq --null-input '{ "V3": [ { "id": { "Concrete": { "parents": 2, "interior": { "X1": { "GlobalConsensus": "Westend" } } } }, "fun": { "Fungible": 3000000000000 } } ] }')" \
343+
"$(jq --null-input '{ "V3": [ { "id": { "Concrete": { "parents": 2, "interior": { "X1": { "GlobalConsensus": "Westend" } } } }, "fun": { "Fungible": '$amount' } } ] }')" \
342344
0 \
343345
"Unlimited"
344346
;;
345347
reserve-transfer-assets-from-asset-hub-westend-local)
348+
amount=$2
346349
ensure_polkadot_js_api
347350
# send WNDs to Alice account on AHR
348351
limited_reserve_transfer_assets \
349352
"ws://127.0.0.1:9010" \
350353
"//Alice" \
351354
"$(jq --null-input '{ "V3": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Rococo" }, { "Parachain": 1000 } ] } } }')" \
352355
"$(jq --null-input '{ "V3": { "parents": 0, "interior": { "X1": { "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } } } } }')" \
353-
"$(jq --null-input '{ "V3": [ { "id": { "Concrete": { "parents": 1, "interior": "Here" } }, "fun": { "Fungible": 5000000000000 } } ] }')" \
356+
"$(jq --null-input '{ "V3": [ { "id": { "Concrete": { "parents": 1, "interior": "Here" } }, "fun": { "Fungible": '$amount' } } ] }')" \
354357
0 \
355358
"Unlimited"
356359
;;
357360
withdraw-reserve-assets-from-asset-hub-westend-local)
361+
amount=$2
358362
ensure_polkadot_js_api
359363
# send back only 100000000000 wrappedROCs to Alice account on AHR
360364
limited_reserve_transfer_assets \
361365
"ws://127.0.0.1:9010" \
362366
"//Alice" \
363367
"$(jq --null-input '{ "V3": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Rococo" }, { "Parachain": 1000 } ] } } }')" \
364368
"$(jq --null-input '{ "V3": { "parents": 0, "interior": { "X1": { "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } } } } }')" \
365-
"$(jq --null-input '{ "V3": [ { "id": { "Concrete": { "parents": 2, "interior": { "X1": { "GlobalConsensus": "Rococo" } } } }, "fun": { "Fungible": 3000000000000 } } ] }')" \
369+
"$(jq --null-input '{ "V3": [ { "id": { "Concrete": { "parents": 2, "interior": { "X1": { "GlobalConsensus": "Rococo" } } } }, "fun": { "Fungible": '$amount' } } ] }')" \
366370
0 \
367371
"Unlimited"
368372
;;

bridges/testing/framework/js-helpers/native-assets-balance-increased.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ async function run(nodeName, networkInfo, args) {
33
const api = await zombie.connect(wsUri, userDefinedTypes);
44

55
const accountAddress = args[0];
6+
const expectedIncrease = BigInt(args[1]);
67
const initialAccountData = await api.query.system.account(accountAddress);
78
const initialAccountBalance = initialAccountData.data['free'];
89
while (true) {
910
const accountData = await api.query.system.account(accountAddress);
1011
const accountBalance = accountData.data['free'];
11-
if (accountBalance > initialAccountBalance) {
12+
if (accountBalance > initialAccountBalance + expectedIncrease) {
1213
return accountBalance;
1314
}
1415

@@ -17,4 +18,4 @@ async function run(nodeName, networkInfo, args) {
1718
}
1819
}
1920

20-
module.exports = { run }
21+
module.exports = {run}

bridges/testing/tests/0001-asset-transfer/roc-reaches-westend.zndsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ Description: User is able to transfer ROC from Rococo Asset Hub to Westend Asset
22
Network: {{ENV_PATH}}/bridge_hub_westend_local_network.toml
33
Creds: config
44

5-
# send ROC to //Alice from Rococo AH to Westend AH
6-
asset-hub-westend-collator1: run {{ENV_PATH}}/helper.sh with "reserve-transfer-assets-from-asset-hub-rococo-local" within 120 seconds
5+
# send 5 ROC to //Alice from Rococo AH to Westend AH
6+
asset-hub-westend-collator1: run {{ENV_PATH}}/helper.sh with "reserve-transfer-assets-from-asset-hub-rococo-local 5000000000000" within 120 seconds
77

8-
# check that //Alice received the ROC on Westend AH
9-
asset-hub-westend-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/wrapped-assets-balance.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,0,Rococo" within 300 seconds
8+
# check that //Alice received at least 4.8 ROC on Westend AH
9+
asset-hub-westend-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/wrapped-assets-balance.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,4800000000000,Rococo" within 300 seconds
1010

1111
# check that the relayer //Charlie is rewarded by Westend AH
1212
bridge-hub-westend-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/relayer-rewards.js with "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y,0x00000002,0x6268726F,ThisChain,0" within 30 seconds

bridges/testing/tests/0001-asset-transfer/wnd-reaches-rococo.zndsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ Description: User is able to transfer WND from Westend Asset Hub to Rococo Asset
22
Network: {{ENV_PATH}}/bridge_hub_rococo_local_network.toml
33
Creds: config
44

5-
# send WND to //Alice from Westend AH to Rococo AH
6-
asset-hub-rococo-collator1: run {{ENV_PATH}}/helper.sh with "reserve-transfer-assets-from-asset-hub-westend-local" within 120 seconds
5+
# send 5 WND to //Alice from Westend AH to Rococo AH
6+
asset-hub-rococo-collator1: run {{ENV_PATH}}/helper.sh with "reserve-transfer-assets-from-asset-hub-westend-local 5000000000000" within 120 seconds
77

8-
# check that //Alice received the WND on Rococo AH
9-
asset-hub-rococo-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/wrapped-assets-balance.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,0,Westend" within 300 seconds
8+
# check that //Alice received at least 4.8 WND on Rococo AH
9+
asset-hub-rococo-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/wrapped-assets-balance.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,4800000000000,Westend" within 300 seconds
1010

1111
# check that the relayer //Charlie is rewarded by Rococo AH
1212
bridge-hub-rococo-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/relayer-rewards.js with "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y,0x00000002,0x62687764,ThisChain,0" within 30 seconds

bridges/testing/tests/0001-asset-transfer/wroc-reaches-rococo.zndsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ Description: User is able to transfer ROC from Rococo Asset Hub to Westend Asset
22
Network: {{ENV_PATH}}/bridge_hub_westend_local_network.toml
33
Creds: config
44

5-
# send wROC back to Alice from Westend AH to Rococo AH
6-
asset-hub-rococo-collator1: run {{ENV_PATH}}/helper.sh with "withdraw-reserve-assets-from-asset-hub-westend-local" within 120 seconds
5+
# send 3 wROC back to Alice from Westend AH to Rococo AH
6+
asset-hub-rococo-collator1: run {{ENV_PATH}}/helper.sh with "withdraw-reserve-assets-from-asset-hub-westend-local 3000000000000" within 120 seconds
77

8-
# check that //Alice received the wROC on Rococo AH
8+
# check that //Alice received at least 2.8 wROC on Rococo AH
99
# (we wait until //Alice account increases here - there are no other transactions that may increase it)
10-
asset-hub-rococo-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/native-assets-balance-increased.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" within 300 seconds
10+
asset-hub-rococo-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/native-assets-balance-increased.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,2800000000000" within 300 seconds

bridges/testing/tests/0001-asset-transfer/wwnd-reaches-westend.zndsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ Description: User is able to transfer ROC from Rococo Asset Hub to Westend Asset
22
Network: {{ENV_PATH}}/bridge_hub_westend_local_network.toml
33
Creds: config
44

5-
# send wWND back to Alice from Rococo AH to Westend AH
6-
asset-hub-westend-collator1: run {{ENV_PATH}}/helper.sh with "withdraw-reserve-assets-from-asset-hub-rococo-local" within 120 seconds
5+
# send 3 wWND back to Alice from Rococo AH to Westend AH
6+
asset-hub-westend-collator1: run {{ENV_PATH}}/helper.sh with "withdraw-reserve-assets-from-asset-hub-rococo-local 3000000000000" within 120 seconds
77

8-
# check that //Alice received the wWND on Westend AH
8+
# check that //Alice received at least 2.8 wWND on Westend AH
99
# (we wait until //Alice account increases here - there are no other transactions that may increase it)
10-
asset-hub-westend-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/native-assets-balance-increased.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" within 300 seconds
10+
asset-hub-westend-collator1: js-script {{FRAMEWORK_PATH}}/js-helpers/native-assets-balance-increased.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,2800000000000" within 300 seconds

0 commit comments

Comments
 (0)