Skip to content

Commit 89d1563

Browse files
authored
Fix tests post AH migration (KUSAMA) (#158)
* Kusama: Removed relay tests + Fixed AH tests + updated snapshots + updated chopsticks * lint
1 parent 7ef7918 commit 89d1563

File tree

7 files changed

+141
-116
lines changed

7 files changed

+141
-116
lines changed

helpers/api/index.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,43 @@ export const xcmPallet = {
206206
0,
207207
'Unlimited',
208208
),
209+
transferAssetsUsingTypeAndThenV3:
210+
(token: any, amount: any, dest: any) =>
211+
({ api }: { api: ApiPromise }, acc: any) =>
212+
(api.tx.xcmPallet || api.tx.polkadotXcm).transferAssetsUsingTypeAndThen(
213+
dest,
214+
{
215+
V3: [
216+
{
217+
id: token,
218+
fun: { Fungible: amount },
219+
},
220+
],
221+
},
222+
'LocalReserve',
223+
{ V3: token },
224+
'LocalReserve',
225+
{
226+
V3: [
227+
{
228+
DepositAsset: {
229+
assets: { Wild: 'All' },
230+
beneficiary: {
231+
parents: 0,
232+
interior: {
233+
X1: {
234+
AccountId32: {
235+
id: acc,
236+
},
237+
},
238+
},
239+
},
240+
},
241+
},
242+
],
243+
},
244+
'Unlimited',
245+
),
209246
}
210247

211248
export const tx = {

networks/statemint.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
endpoint: 'wss://polkadot-asset-hub-rpc.polkadot.io',
77
},
88
kusama: {
9-
name: 'statemine' as const,
9+
name: 'assethub' as const,
1010
endpoint: 'wss://kusama-asset-hub-rpc.polkadot.io',
1111
},
1212
config: ({ alice }) => ({
@@ -16,7 +16,7 @@ export default {
1616
},
1717
Assets: {
1818
account: [
19-
[[statemine.usdtIndex, alice.address], { balance: 1000e6 }], // USDT
19+
[[assethub.usdtIndex, alice.address], { balance: 1000e6 }], // USDT
2020
],
2121
},
2222
},
@@ -32,7 +32,7 @@ export const statemint = {
3232
usdtIndex: 1984,
3333
} as const
3434

35-
export const statemine = {
35+
export const assethub = {
3636
paraId: 1000,
3737
ksm: { Concrete: { parents: 1, interior: 'Here' } },
3838
usdt: { Concrete: { parents: 0, interior: { X2: [{ PalletInstance: 50 }, { GeneralIndex: 1984 }] } } },

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"update-env": "tsx scripts/update-env.ts"
1414
},
1515
"dependencies": {
16-
"@acala-network/chopsticks": "^1.2.1",
17-
"@acala-network/chopsticks-testing": "^1.2.1",
16+
"@acala-network/chopsticks": "^1.2.2",
17+
"@acala-network/chopsticks-testing": "^1.2.2",
1818
"@polkadot/api": "^16.4.5",
1919
"@swc/core": "^1.13.5",
2020
"axios": "^1.11.0",

tests/xcm-transfer/__snapshots__/shiden-asset-hub.test.ts.snap

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`Shiden & AssetHub > 001: Transfer KSM from AssetHub (statemine) to Shiden > 001: shiden event 1`] = `
3+
exports[`Shiden & AssetHub > 001: Transfer KSM from AssetHub to Shiden > 001: shiden event 1`] = `
44
[
55
{
66
"data": {
@@ -10,8 +10,8 @@ exports[`Shiden & AssetHub > 001: Transfer KSM from AssetHub (statemine) to Shid
1010
},
1111
"success": true,
1212
"weightUsed": {
13-
"proofSize": "(rounded 9300)",
14-
"refTime": "(rounded 900000000)",
13+
"proofSize": "(rounded 340000)",
14+
"refTime": "(rounded 29000000000)",
1515
},
1616
},
1717
"method": "Processed",
@@ -20,7 +20,7 @@ exports[`Shiden & AssetHub > 001: Transfer KSM from AssetHub (statemine) to Shid
2020
]
2121
`;
2222

23-
exports[`Shiden & AssetHub > 001: Transfer KSM from AssetHub (statemine) to Shiden > 001: statemine ump messages 1`] = `
23+
exports[`Shiden & AssetHub > 001: Transfer KSM from AssetHub to Shiden > 001: statemine ump messages 1`] = `
2424
[
2525
{
2626
"data": [
@@ -67,7 +67,7 @@ exports[`Shiden & AssetHub > 001: Transfer KSM from AssetHub (statemine) to Shid
6767
"depositAsset": {
6868
"assets": {
6969
"wild": {
70-
"allCounted": 1,
70+
"all": null,
7171
},
7272
},
7373
"beneficiary": {
@@ -95,3 +95,25 @@ exports[`Shiden & AssetHub > 001: Transfer KSM from AssetHub (statemine) to Shid
9595
},
9696
]
9797
`;
98+
99+
exports[`Shiden & AssetHub > 002: Transfer KSM from Shiden to Asset Hub > 002: asset hub event 1`] = `
100+
[
101+
{
102+
"data": {
103+
"id": "(hash)",
104+
"origin": {
105+
"Sibling": "(rounded 2000)",
106+
},
107+
"success": true,
108+
"weightUsed": {
109+
"proofSize": "(rounded 11000)",
110+
"refTime": "(rounded 1000000000)",
111+
},
112+
},
113+
"method": "Processed",
114+
"section": "messageQueue",
115+
},
116+
]
117+
`;
118+
119+
exports[`Shiden & AssetHub > 002: Transfer KSM from Shiden to Asset Hub > 002: shiden event 1`] = `[]`;

tests/xcm-transfer/kusama-shiden.test.ts

Lines changed: 0 additions & 62 deletions
This file was deleted.

tests/xcm-transfer/shiden-asset-hub.test.ts

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ import { checkHrmp, checkSystemEvents, given } from '../../helpers'
22
import { describe, expect } from 'vitest'
33
import { query, tx } from '../../helpers/api'
44
import { shiden as shidenUtil } from '../../networks/astar'
5-
import { statemine as statemineUtil } from '../../networks/statemint'
5+
import { assethub as assethubUtil } from '../../networks/statemint'
66

77
describe('Shiden & AssetHub', () => {
8-
given('shiden', 'statemine')(
9-
'001: Transfer KSM from AssetHub (statemine) to Shiden',
10-
async ({ networks: { shiden, statemine }, keyring: { alice, bob } }) => {
8+
given('shiden', 'assethub')(
9+
'001: Transfer KSM from AssetHub to Shiden',
10+
async ({ networks: { shiden, assethub }, keyring: { alice, bob } }) => {
1111
await tx.xcmPallet
12-
.limitedReserveTransferAssetsV3(statemineUtil.ksm, 1e12, tx.xcmPallet.parachainV3(
12+
.transferAssetsUsingTypeAndThenV3(assethubUtil.ksm, 1e12, tx.xcmPallet.parachainV3(
1313
1,
1414
shidenUtil.paraId,
15-
))(statemine, bob.addressRaw)
15+
))(assethub, bob.addressRaw)
1616
.signAndSend(alice)
1717

18-
await statemine.chain.newBlock()
18+
await assethub.chain.newBlock()
1919

20-
await checkHrmp(statemine)
20+
await checkHrmp(assethub)
2121
.redact({ redactKeys: /setTopic/ })
2222
.toMatchSnapshot('001: statemine ump messages')
2323

@@ -26,11 +26,39 @@ describe('Shiden & AssetHub', () => {
2626
const bobBalance = await query.assets(shidenUtil.ksm)(shiden, bob.address)
2727
expect(bobBalance.unwrap().balance.toNumber()).closeTo(
2828
1_000_000_000_000,
29-
1_000_000, // some fee
29+
1e8, // some fee
3030
'Expected amount was not received',
3131
)
3232

3333
await checkSystemEvents(shiden, 'xcmpQueue', 'messageQueue').toMatchSnapshot('001: shiden event')
3434
},
3535
)
3636
})
37+
38+
describe('Shiden & AssetHub', () => {
39+
given('shiden', 'assethub')(
40+
'002: Transfer KSM from Shiden to Asset Hub',
41+
async ({ networks: { shiden, assethub }, keyring: { alice, bob } }) => {
42+
await tx.xtokens
43+
.transfer(shidenUtil.ksm, 1e12, tx.xtokens.parachainV3(assethubUtil.paraId))(shiden, bob.addressRaw)
44+
.signAndSend(alice)
45+
46+
await shiden.chain.newBlock()
47+
48+
await checkSystemEvents(shiden, 'parachainSystem', 'dmpQueue', 'messageQueue').toMatchSnapshot(
49+
'002: shiden event',
50+
)
51+
52+
await assethub.chain.newBlock()
53+
54+
const bobBalance = await assethub.api.query.system.account(bob.address)
55+
expect(bobBalance.data.free.toNumber()).closeTo(
56+
1e12,
57+
1e9, // some fee
58+
'Expected amount was not received',
59+
)
60+
61+
await checkSystemEvents(assethub, 'messageQueue').toMatchSnapshot('002: asset hub event')
62+
},
63+
)
64+
})

0 commit comments

Comments
 (0)