Skip to content

Commit d92dbc9

Browse files
ntn-x2Ad96el
andauthored
fix: outdated integration tests (#632)
Fixes KILTprotocol/ticket#3344. Integration tests are outdated. Since KILT is now listed on HydraDX, any tokens sent to the Omnipool account is automatically transferred to the treasury, which makes the test cases fail. The integration test logic must be updated to test the following: 1. Send KILT tokens from a KILT account to **its own** sovereign account on HydraDX (implementation started in this PR for the V2 tests) 2. Send KILT tokens from HydraDX back to KILT (to implement in this PR) --------- Co-authored-by: Adel Golghalyani <[email protected]>
1 parent 9a69512 commit d92dbc9

12 files changed

+162
-127
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ integration-tests:
4141
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
4242
- export NVM_DIR="$HOME/.nvm" && . "$NVM_DIR/nvm.sh" --no-use
4343
- eval "[ -f .nvmrc ] && nvm install" && nvm use
44-
- cargo build -p spiritnet-runtime
4544
- yarn --immutable
45+
- yarn ts-check
4646
- yarn lint
4747
- yarn test:CI
4848

integration-tests/chopsticks/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@
3030
"eslint-plugin-jsx-a11y": "^6.8.0"
3131
},
3232
"scripts": {
33+
"ts-check": "tsc --noEmit",
3334
"lint": "eslint src && prettier --check src",
3435
"lint:fix": "eslint --fix src && prettier --write src",
35-
"clean": "rm -rf ./db && cargo build -p spiritnet-runtime",
36+
"clean": "rm -rf ./db",
3637
"test": "LOG_LEVEL=error vitest",
3738
"test:CI": "vitest --bail 0 --no-file-parallelism"
3839
}

integration-tests/chopsticks/src/network/hydraDx.ts

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { setupContext, SetupOption } from '@acala-network/chopsticks-testing'
22
import type { Config } from './types.js'
3-
import * as SpiritnetConfig from './spiritnet.js'
43
import { initialBalanceHDX, initialBalanceKILT, toNumber } from '../utils.js'
54

65
/// Options used to create the HydraDx context
@@ -10,7 +9,7 @@ export const options: SetupOption = {
109
port: toNumber(process.env.HYDRADX_PORT) || 9001,
1110
}
1211

13-
export const kiltTokenId = 60
12+
export const kiltTokenId = 28
1413

1514
/// Sets the [TechnicalCommittee] and [Council] governance to the given accounts
1615
export function setGovernance(addr: string[]) {
@@ -38,38 +37,10 @@ export function assignKiltTokensToAccounts(addr: string[], balance: bigint = ini
3837
}
3938
}
4039

41-
/// Register KILT into HydraDX and allow KILT as payment
42-
export function registerKilt() {
43-
return {
44-
assetRegistry: {
45-
assetLocations: [[[kiltTokenId], { parents: 1, interior: { X1: { Parachain: SpiritnetConfig.paraId } } }]],
46-
assetIds: [[['KILT'], kiltTokenId]],
47-
locationAssets: [[[{ parents: 1, interior: { X1: { Parachain: SpiritnetConfig.paraId } } }], kiltTokenId]],
48-
assets: [
49-
[
50-
[kiltTokenId],
51-
{
52-
name: 'KILT',
53-
assetType: 'Token',
54-
existentialDeposit: 500,
55-
symbol: 'KILT',
56-
decimals: 18,
57-
xcmRateLimit: null,
58-
isSufficient: true,
59-
},
60-
],
61-
],
62-
},
63-
multiTransactionPayment: {
64-
acceptedCurrencies: [[[kiltTokenId], 100_000]],
65-
},
66-
}
67-
}
68-
6940
/// HydraDX ParaId
7041
export const paraId = 2034
7142

72-
/// OmniPool account
43+
/// Omnipool account
7344
export const omnipoolAccount = '7L53bUTBbfuj14UpdCNPwmgzzHSsrsTWBHX5pys32mVWM3C1'
7445

7546
export async function getContext(): Promise<Config> {

integration-tests/chopsticks/src/network/spiritnet.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ const options: SetupOption = {
77
endpoint: process.env.SPIRITNET_WS || 'wss://kilt-rpc.dwellir.com',
88
db: './db/spiritnet.db.sqlite',
99
port: toNumber(process.env.SPIRITNET_PORT) || 9002,
10-
wasmOverride: '../../target/debug/wbuild/spiritnet-runtime/spiritnet_runtime.wasm',
11-
// Whether to allow WASM unresolved imports when using a WASM to build the parachain. This Flag is needed otherwise, the runtime can not be built from the WASM. Chopsticks throws an error when it encounters an unresolved import.
12-
allowUnresolvedImports: true,
1310
}
1411

1512
/// Assigns the native tokens to an accounts
@@ -29,15 +26,6 @@ export function setGovernance(addr: string[]) {
2926
}
3027
}
3128

32-
/// Sets the [safeXcmVersion] to the given version
33-
export function setSafeXcmVersion(version: number) {
34-
return {
35-
polkadotXcm: {
36-
safeXcmVersion: version,
37-
},
38-
}
39-
}
40-
4129
/// Spiritnet ParaId
4230
export const paraId = 2086
4331

integration-tests/chopsticks/src/tests/index.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import * as SpiritnetConfig from '../network/spiritnet.js'
66
import * as PolkadotConfig from '../network/polkadot.js'
77
import * as HydraDxConfig from '../network/hydraDx.js'
88
import type { Config } from '../network/types.js'
9-
import { setStorage } from './utils.js'
109

1110
export let spiritnetContext: Config
1211
export let hydradxContext: Config
@@ -18,8 +17,11 @@ beforeAll(async () => {
1817
polkadotContext = await PolkadotConfig.getContext()
1918

2019
// Setup network
20+
//@ts-expect-error Something weird in the exported types
2121
await connectVertical(polkadotContext.chain, spiritnetContext.chain)
22+
//@ts-expect-error Something weird in the exported types
2223
await connectVertical(polkadotContext.chain, hydradxContext.chain)
24+
//@ts-expect-error Something weird in the exported types
2325
await connectParachains([spiritnetContext.chain, hydradxContext.chain])
2426

2527
const newBlockConfig = { count: 2 }
@@ -31,14 +33,6 @@ beforeAll(async () => {
3133
spiritnetContext.dev.newBlock(newBlockConfig),
3234
hydradxContext.dev.newBlock(newBlockConfig),
3335
])
34-
35-
console.info('Runtime Upgrade completed')
36-
37-
// set SafeXcmVersion to 3
38-
await setStorage(spiritnetContext, SpiritnetConfig.setSafeXcmVersion(3))
39-
40-
// register Kilt in HydraDX
41-
await setStorage(hydradxContext, HydraDxConfig.registerKilt())
4236
}, 300_000)
4337

4438
afterAll(async () => {

integration-tests/chopsticks/src/tests/utils.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ export async function checkBalance(
3030
expect(balance).eq(BigInt(expectedAmount))
3131
}
3232

33+
/// checks the balance of an account and expects it to be in the given range
34+
export async function checkBalanceInRange(
35+
getFreeBalanceFunction: (account: string) => Promise<bigint>,
36+
account: string,
37+
expect: ExpectStatic,
38+
expectedRange: [bigint, bigint]
39+
) {
40+
const balance = await getFreeBalanceFunction(account)
41+
expect(balance >= expectedRange[0])
42+
expect(balance <= expectedRange[1])
43+
}
44+
3345
export function hexAddress(addr: string) {
3446
return u8aToHex(decodeAddress(addr))
3547
}

integration-tests/chopsticks/src/tests/xcm/__snapshots__/limitedReserveTransferSpiritnetHydraDxV2.test.ts.snap

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

3-
exports[`Limited Reserve V2 Transfers from Spiritnet Account Alice -> HydraDx > receiver events currencies 1`] = `
3+
exports[`Limited Reserve V2 Transfers from Spiritnet Account Alice -> HydraDx Account Alice > receiver events currencies 1`] = `
44
[
55
{
66
"data": {
7-
"amount": 1000000000000000,
8-
"currencyId": 60,
9-
"who": "7L53bUTBbfuj14UpdCNPwmgzzHSsrsTWBHX5pys32mVWM3C1",
7+
"amount": "(rounded 990000000000000)",
8+
"currencyId": 28,
9+
"who": "7NL1GYCJu8cFSnWBLwET2X3fMdodw8T75zuxi59hA2bhdjQq",
10+
},
11+
"method": "Deposited",
12+
"section": "currencies",
13+
},
14+
{
15+
"data": {
16+
"amount": "(rounded 5000000000000)",
17+
"currencyId": 28,
18+
"who": "7L53bUTBopuwFt3mKUfmkzgGLayYa1Yvn1hAg9v5UMrQzTfh",
1019
},
1120
"method": "Deposited",
1221
"section": "currencies",
1322
},
1423
]
1524
`;
1625

17-
exports[`Limited Reserve V2 Transfers from Spiritnet Account Alice -> HydraDx > receiver events xcmpQueue 1`] = `
26+
exports[`Limited Reserve V2 Transfers from Spiritnet Account Alice -> HydraDx Account Alice > receiver events xcmpQueue 1`] = `
1827
[
1928
{
2029
"data": {
@@ -31,7 +40,7 @@ exports[`Limited Reserve V2 Transfers from Spiritnet Account Alice -> HydraDx >
3140
]
3241
`;
3342

34-
exports[`Limited Reserve V2 Transfers from Spiritnet Account Alice -> HydraDx > sender events Balances 1`] = `
43+
exports[`Limited Reserve V2 Transfers from Spiritnet Account Alice -> HydraDx Account Alice > sender events Balances 1`] = `
3544
[
3645
{
3746
"data": {
@@ -44,7 +53,7 @@ exports[`Limited Reserve V2 Transfers from Spiritnet Account Alice -> HydraDx >
4453
]
4554
`;
4655

47-
exports[`Limited Reserve V2 Transfers from Spiritnet Account Alice -> HydraDx > sender events xcm pallet 1`] = `
56+
exports[`Limited Reserve V2 Transfers from Spiritnet Account Alice -> HydraDx Account Alice > sender events xcm pallet 1`] = `
4857
[
4958
{
5059
"data": {
@@ -61,7 +70,7 @@ exports[`Limited Reserve V2 Transfers from Spiritnet Account Alice -> HydraDx >
6170
]
6271
`;
6372

64-
exports[`Limited Reserve V2 Transfers from Spiritnet Account Alice -> HydraDx > sender events xcm queue pallet 1`] = `
73+
exports[`Limited Reserve V2 Transfers from Spiritnet Account Alice -> HydraDx Account Alice > sender events xcm queue pallet 1`] = `
6574
[
6675
{
6776
"data": {

integration-tests/chopsticks/src/tests/xcm/__snapshots__/limitedReserveTransferSpiritnetHydraDxV3.test.ts.snap

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

3-
exports[`Limited Reserve V3 Transfers from Spiritnet Account Alice -> HydraDx > receiver events currencies 1`] = `
3+
exports[`Limited Reserve V3 Transfers from Spiritnet Account Alice -> HydraDx Account Alice > receiver events currencies 1`] = `
44
[
55
{
66
"data": {
7-
"amount": 1000000000000000,
8-
"currencyId": 60,
9-
"who": "7L53bUTBbfuj14UpdCNPwmgzzHSsrsTWBHX5pys32mVWM3C1",
7+
"amount": "(rounded 990000000000000)",
8+
"currencyId": 28,
9+
"who": "7NL1GYCJu8cFSnWBLwET2X3fMdodw8T75zuxi59hA2bhdjQq",
10+
},
11+
"method": "Deposited",
12+
"section": "currencies",
13+
},
14+
{
15+
"data": {
16+
"amount": "(rounded 5000000000000)",
17+
"currencyId": 28,
18+
"who": "7L53bUTBopuwFt3mKUfmkzgGLayYa1Yvn1hAg9v5UMrQzTfh",
1019
},
1120
"method": "Deposited",
1221
"section": "currencies",
1322
},
1423
]
1524
`;
1625

17-
exports[`Limited Reserve V3 Transfers from Spiritnet Account Alice -> HydraDx > receiver events xcmpQueue 1`] = `
26+
exports[`Limited Reserve V3 Transfers from Spiritnet Account Alice -> HydraDx Account Alice > receiver events xcmpQueue 1`] = `
1827
[
1928
{
2029
"data": {
@@ -31,7 +40,7 @@ exports[`Limited Reserve V3 Transfers from Spiritnet Account Alice -> HydraDx >
3140
]
3241
`;
3342

34-
exports[`Limited Reserve V3 Transfers from Spiritnet Account Alice -> HydraDx > sender events Balances 1`] = `
43+
exports[`Limited Reserve V3 Transfers from Spiritnet Account Alice -> HydraDx Account Alice > sender events Balances 1`] = `
3544
[
3645
{
3746
"data": {
@@ -44,7 +53,7 @@ exports[`Limited Reserve V3 Transfers from Spiritnet Account Alice -> HydraDx >
4453
]
4554
`;
4655

47-
exports[`Limited Reserve V3 Transfers from Spiritnet Account Alice -> HydraDx > sender events xcm pallet 1`] = `
56+
exports[`Limited Reserve V3 Transfers from Spiritnet Account Alice -> HydraDx Account Alice > sender events xcm pallet 1`] = `
4857
[
4958
{
5059
"data": {
@@ -61,7 +70,7 @@ exports[`Limited Reserve V3 Transfers from Spiritnet Account Alice -> HydraDx >
6170
]
6271
`;
6372

64-
exports[`Limited Reserve V3 Transfers from Spiritnet Account Alice -> HydraDx > sender events xcm queue pallet 1`] = `
73+
exports[`Limited Reserve V3 Transfers from Spiritnet Account Alice -> HydraDx Account Alice > sender events xcm queue pallet 1`] = `
6574
[
6675
{
6776
"data": {

integration-tests/chopsticks/src/tests/xcm/__snapshots__/limitedReseveTransferHydraDxSpiritnet.test.ts.snap

Lines changed: 10 additions & 10 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[`Limited Reserve Transfers from HydraDx Account Bob -> Spiritnet > receiver events Balances 1`] = `
3+
exports[`Limited Reserve Transfers from HydraDx Account Alice -> Spiritnet Account Alice > receiver events Balances 1`] = `
44
[
55
{
66
"data": {
@@ -13,7 +13,7 @@ exports[`Limited Reserve Transfers from HydraDx Account Bob -> Spiritnet > recei
1313
]
1414
`;
1515

16-
exports[`Limited Reserve Transfers from HydraDx Account Bob -> Spiritnet > receiver events Balances 2`] = `
16+
exports[`Limited Reserve Transfers from HydraDx Account Alice -> Spiritnet Account Alice > receiver events Balances 2`] = `
1717
[
1818
{
1919
"data": {
@@ -26,7 +26,7 @@ exports[`Limited Reserve Transfers from HydraDx Account Bob -> Spiritnet > recei
2626
]
2727
`;
2828

29-
exports[`Limited Reserve Transfers from HydraDx Account Bob -> Spiritnet > receiver events xcmpQueue 1`] = `
29+
exports[`Limited Reserve Transfers from HydraDx Account Alice -> Spiritnet Account Alice > receiver events xcmpQueue 1`] = `
3030
[
3131
{
3232
"data": {
@@ -43,30 +43,30 @@ exports[`Limited Reserve Transfers from HydraDx Account Bob -> Spiritnet > recei
4343
]
4444
`;
4545

46-
exports[`Limited Reserve Transfers from HydraDx Account Bob -> Spiritnet > sender events currencies 1`] = `
46+
exports[`Limited Reserve Transfers from HydraDx Account Alice -> Spiritnet Account Alice > sender events currencies 1`] = `
4747
[
4848
{
4949
"data": {
5050
"amount": "(rounded 440000000000)",
5151
"currencyId": 0,
52-
"who": "7MZG43idRmdg8VSt5BS9mVJeBhhxxt5y55hCsMpoKp5xFQX2",
52+
"who": "7NL1GYCJu8cFSnWBLwET2X3fMdodw8T75zuxi59hA2bhdjQq",
5353
},
5454
"method": "Withdrawn",
5555
"section": "currencies",
5656
},
5757
{
5858
"data": {
5959
"amount": 1000000000000000,
60-
"currencyId": 60,
61-
"who": "7MZG43idRmdg8VSt5BS9mVJeBhhxxt5y55hCsMpoKp5xFQX2",
60+
"currencyId": 28,
61+
"who": "7NL1GYCJu8cFSnWBLwET2X3fMdodw8T75zuxi59hA2bhdjQq",
6262
},
6363
"method": "Withdrawn",
6464
"section": "currencies",
6565
},
6666
]
6767
`;
6868

69-
exports[`Limited Reserve Transfers from HydraDx Account Bob -> Spiritnet > sender events currencies 2`] = `
69+
exports[`Limited Reserve Transfers from HydraDx Account Alice -> Spiritnet Account Alice > sender events currencies 2`] = `
7070
[
7171
{
7272
"data": {
@@ -118,15 +118,15 @@ exports[`Limited Reserve Transfers from HydraDx Account Bob -> Spiritnet > sende
118118
},
119119
},
120120
},
121-
"sender": "7MZG43idRmdg8VSt5BS9mVJeBhhxxt5y55hCsMpoKp5xFQX2",
121+
"sender": "7NL1GYCJu8cFSnWBLwET2X3fMdodw8T75zuxi59hA2bhdjQq",
122122
},
123123
"method": "TransferredMultiAssets",
124124
"section": "xTokens",
125125
},
126126
]
127127
`;
128128

129-
exports[`Limited Reserve Transfers from HydraDx Account Bob -> Spiritnet > sender events xcm queue pallet 1`] = `
129+
exports[`Limited Reserve Transfers from HydraDx Account Alice -> Spiritnet Account Alice > sender events xcm queue pallet 1`] = `
130130
[
131131
{
132132
"data": {

0 commit comments

Comments
 (0)