Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: integration tests chopsticks #614

Merged
merged 181 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from 168 commits
Commits
Show all changes
181 commits
Select commit Hold shift + click to select a range
7552756
Move XCM configs into XCM file for Peregrine
ntn-x2 Jan 17, 2024
f350b79
Update peregrine
ntn-x2 Jan 18, 2024
6ee00fc
More Peregrine configuration
ntn-x2 Jan 18, 2024
1772afd
XCM emulator environment compiling
ntn-x2 Jan 18, 2024
1395555
Refine XCM emulator setup
ntn-x2 Jan 18, 2024
38f2eab
Test failing but compiling properly
ntn-x2 Jan 19, 2024
6ee9d79
Progress on the XCM tests
ntn-x2 Jan 19, 2024
62ec04f
Network reset before each test
ntn-x2 Jan 23, 2024
35eb1ad
Add chopstick setup to Spiritnet + HydraDX
ntn-x2 Jan 30, 2024
c40887e
Merge branch 'develop' into aa/xcm-asset-transfer
weichweich Feb 14, 2024
466158a
fix key generation
weichweich Feb 14, 2024
80d2517
fix reserve asset test
weichweich Feb 14, 2024
8ac3825
refactor: don't call the chain Runtime
weichweich Feb 14, 2024
5d24518
move integration tests to folder
weichweich Feb 14, 2024
74cbbce
compiling tests
weichweich Feb 19, 2024
ff1bb14
remove unused
weichweich Feb 19, 2024
ebfa9d7
update universal location & reserve
weichweich Feb 21, 2024
1458e2f
make tests compile
weichweich Feb 21, 2024
1887241
add ParentOrSibling match type
weichweich Feb 21, 2024
2c282a6
adjusted config
weichweich Feb 21, 2024
303d32e
fix test
weichweich Feb 22, 2024
a41f38d
update test config
weichweich Feb 24, 2024
9257593
teleport should be filtered
weichweich Feb 24, 2024
1cefad5
add penpal
weichweich Feb 24, 2024
a2b511c
remove penpal
weichweich Feb 24, 2024
91e2e10
remove penpal
weichweich Feb 27, 2024
4ab2dc7
to remove
Ad96el Feb 28, 2024
1aeedad
compiling
Ad96el Feb 29, 2024
f8006f3
test working and compiling
Ad96el Feb 29, 2024
08ddade
refactored
Ad96el Feb 29, 2024
578ce31
intermediate state
Ad96el Mar 5, 2024
7f663b1
first sudo calls
Ad96el Mar 5, 2024
ed88295
refactor: change naming
Ad96el Mar 7, 2024
82a58f4
add tests to send asset from asset hub to spiritnet
Ad96el Mar 7, 2024
e7ea448
working creating did from other chain
Ad96el Mar 10, 2024
49f6dcd
safecall filter
Ad96el Mar 10, 2024
42c6023
finish spirtnet
Ad96el Mar 11, 2024
1bea2c7
finish peregrine
Ad96el Mar 11, 2024
ad6f9bc
intermediate state cargo toml
Ad96el Mar 11, 2024
dfbda84
clean up cargo.toml
Ad96el Mar 11, 2024
67651ce
clean up reserve transfers peregrine
Ad96el Mar 11, 2024
ee4823b
clean up reserve transfers spiritnet
Ad96el Mar 11, 2024
36d4a89
use structs
Ad96el Mar 11, 2024
742ef08
rename function
Ad96el Mar 11, 2024
d84e2d1
Merge branch 'develop' into aa/xcm-asset-transfer
Ad96el Mar 11, 2024
31e9622
remove println
Ad96el Mar 11, 2024
f4bcd6e
Merge branch 'aa/xcm-asset-transfer' of github.com:KILTprotocol/kilt-…
Ad96el Mar 11, 2024
30c5afb
make it compile
Ad96el Mar 12, 2024
6cec768
clean up
Ad96el Mar 12, 2024
bcc4a6a
allow sovereign account
Ad96el Mar 12, 2024
23a9738
clippy
Ad96el Mar 12, 2024
7799488
remove chopsticks
Ad96el Mar 13, 2024
cf81073
create locationToAccount for networks
Ad96el Mar 13, 2024
a34345a
remove pub
Ad96el Mar 13, 2024
b7598f2
remove refund
Ad96el Mar 13, 2024
f69bbd7
change import
Ad96el Mar 13, 2024
c450875
remove zombienet :(
Ad96el Mar 13, 2024
30e2dd4
check event output
Ad96el Mar 13, 2024
83abcdf
check balance on hold
Ad96el Mar 13, 2024
8a0fddc
replace Spiritnet with Peregrine
Ad96el Mar 13, 2024
7f1016c
remove println
Ad96el Mar 13, 2024
4d6b9af
change error type for test
Ad96el Mar 13, 2024
985132c
change comments
Ad96el Mar 13, 2024
4b5526b
simplify tests
Ad96el Mar 13, 2024
d999788
simplify tests
Ad96el Mar 13, 2024
f0ae357
first draft
Ad96el Mar 14, 2024
5f86edf
add tests for all sudo pallets
Ad96el Mar 14, 2024
57d564f
rename converter
Ad96el Mar 14, 2024
f042871
check did failed by other origin kinds
Ad96el Mar 14, 2024
d30d226
take deposit from runtime
Ad96el Mar 14, 2024
0d8ed2c
remove unit
Ad96el Mar 14, 2024
ab54319
update comments
Ad96el Mar 14, 2024
2387069
add tests for did palltes
Ad96el Mar 14, 2024
2bd3fe5
add all did call tests
Ad96el Mar 19, 2024
3b06313
update configuration
Ad96el Mar 20, 2024
a4a36db
finish did pallets
Ad96el Mar 20, 2024
e35867c
test unpaid execution from relay
Ad96el Mar 20, 2024
6faae52
add licencse
Ad96el Mar 20, 2024
6b79eb1
refactor: mock did
Ad96el Mar 20, 2024
94c2e70
clippy
Ad96el Mar 20, 2024
66bd959
update comment
Ad96el Mar 20, 2024
b49fd88
update comment
Ad96el Mar 20, 2024
997783e
Merge branch 'develop' into aa/xcm-asset-transfer
Ad96el Mar 20, 2024
11e1065
update lockfile
Ad96el Mar 20, 2024
1153214
Merge branch 'aa/xcm-asset-transfer' of github.com:KILTprotocol/kilt-…
Ad96el Mar 20, 2024
8c6612f
update lockfile
Ad96el Mar 20, 2024
2764cf8
first draft
Ad96el Mar 20, 2024
0b1ad37
Fix lockfile
ntn-x2 Mar 21, 2024
b2cb68a
Fix public credential test case
ntn-x2 Mar 21, 2024
ddbecc1
Fix cargo lock
ntn-x2 Mar 21, 2024
d9daae8
Allow unpaid execution from parent sudo
ntn-x2 Mar 21, 2024
7305135
update xcm configs
Ad96el Mar 21, 2024
01ca562
rename varaibles
Ad96el Mar 21, 2024
08bbdb1
fix all tests
Ad96el Mar 21, 2024
9fee381
Merge branch 'aa/xcm-asset-transfer' into ag_integration_tests_chopst…
Ad96el Mar 21, 2024
c872887
first draft
Ad96el Mar 21, 2024
bd86c04
first draft
Ad96el Mar 21, 2024
64deb54
working network
Ad96el Mar 22, 2024
b2d3d15
update weights
Ad96el Mar 22, 2024
4269dcd
update comments
Ad96el Mar 22, 2024
e8fab68
intermediate
Ad96el Mar 25, 2024
37f4734
feat: spinup network
Ad96el Mar 25, 2024
54f1719
feat: first mvp
Ad96el Mar 26, 2024
319d5f9
refactor: network config
Ad96el Mar 26, 2024
34988a0
refactor: network config
Ad96el Mar 26, 2024
8fc0d06
remove comments
Ad96el Mar 26, 2024
6df2c9c
rename varaibles
Ad96el Mar 26, 2024
028f06b
rename varaibles
Ad96el Mar 26, 2024
bdb5f2d
move nvmrc
Ad96el Mar 27, 2024
91a1d8d
rename file
Ad96el Mar 27, 2024
46f5119
env variable
Ad96el Mar 27, 2024
2a95581
comment
Ad96el Mar 27, 2024
48626b5
update package.json
Ad96el Mar 27, 2024
35f7268
update tsconfig
Ad96el Mar 27, 2024
58b6caa
updating comment for xcm
Ad96el Mar 27, 2024
3f16f58
todo adjust key encoding
Ad96el Mar 27, 2024
02932c8
broken state
Ad96el Mar 28, 2024
2aa45c8
working
Ad96el Mar 28, 2024
c77a161
not working
Ad96el Mar 28, 2024
901f789
working
Ad96el Mar 28, 2024
0394f86
working
Ad96el Mar 31, 2024
b647c03
remove emulated
Ad96el Mar 31, 2024
db341d0
Merge branch 'develop' into ag_integration_tests_chopsticks
Ad96el Mar 31, 2024
23c0622
revert lock
Ad96el Mar 31, 2024
4364c55
revert lock
Ad96el Mar 31, 2024
14685b2
revert toml
Ad96el Mar 31, 2024
9f226d7
check balance
Ad96el Mar 31, 2024
4f63eef
remove promise in setTimeout
Ad96el Apr 2, 2024
d499192
rename package name
Ad96el Apr 2, 2024
d48844b
reduce timeout
Ad96el Apr 2, 2024
ea2fa38
check balance before tx
Ad96el Apr 2, 2024
71a810b
Change comment of tests
Ad96el Apr 2, 2024
95256c5
check balance of alice
Ad96el Apr 2, 2024
8ef87a6
Merge branch 'develop' into ag_integration_tests_chopsticks
Ad96el Apr 8, 2024
d017509
Merge branch 'develop' into ag_integration_tests_chopsticks
Ad96el Apr 15, 2024
1d81adf
Merge branch 'ag_integration_tests_chopsticks' of github.com:KILTprot…
Ad96el Apr 15, 2024
6031e34
remove spinup network
Ad96el Apr 15, 2024
e2595f0
update comment
Ad96el Apr 15, 2024
ffc4613
update storage
Ad96el Apr 15, 2024
a2d6393
remove version
Ad96el Apr 15, 2024
2eb915f
add comments
Ad96el Apr 15, 2024
0a4c2a9
intermediate
Ad96el Apr 15, 2024
244fc6a
refactor spiritnet -> hydra
Ad96el Apr 15, 2024
af37ea4
finished
Ad96el Apr 15, 2024
c00a2d1
working spiritnet -> hydra
Ad96el Apr 15, 2024
823468d
split v2 and v3
Ad96el Apr 15, 2024
ad89a04
rename variable
Ad96el Apr 15, 2024
f8621a2
update gitignore
Ad96el Apr 15, 2024
b05aacf
add to CI
Ad96el Apr 15, 2024
985024e
fmt
Ad96el Apr 15, 2024
fc3ad0d
lint to ci
Ad96el Apr 15, 2024
328813f
update rule
Ad96el Apr 15, 2024
635ba9a
test
Ad96el Apr 16, 2024
a300704
working typesprict part
Ad96el Apr 16, 2024
075e9e8
target
Ad96el Apr 16, 2024
585c20b
build runtime
Ad96el Apr 16, 2024
e3fd9bd
try withouth sudo
Ad96el Apr 16, 2024
8f9dbc1
uncomment
Ad96el Apr 16, 2024
bec955e
renamed variables + comments
Ad96el Apr 17, 2024
41c2859
rename functions
Ad96el Apr 17, 2024
b3b551b
make it run
Ad96el Apr 17, 2024
e6e5f44
change order
Ad96el Apr 17, 2024
0ebcde8
update balance checks
Ad96el Apr 18, 2024
63a0d0c
update CI
Ad96el Apr 18, 2024
6e25909
--immutable
Ad96el Apr 18, 2024
5905280
update packages
Ad96el Apr 18, 2024
e198397
Merge branch 'develop' into ag_integration_tests_chopsticks
ntn-x2 Apr 18, 2024
b0bbb50
Merge branch 'develop' into ag_integration_tests_chopsticks
Ad96el Apr 18, 2024
7b4f251
working
Ad96el Apr 18, 2024
3b24c9a
Increase timeout
ntn-x2 Apr 19, 2024
6d1d131
update chopsticks, use nvm, remove flags
Ad96el Apr 19, 2024
cfb5fee
env variable
Ad96el Apr 19, 2024
b7d45a9
env variable
Ad96el Apr 19, 2024
f4d91fd
set number
Ad96el Apr 19, 2024
6f8497f
try isolate
Ad96el Apr 19, 2024
ce9bbcb
increase timeout
Ad96el Apr 19, 2024
e0824de
increase timeout
Ad96el Apr 21, 2024
7d80eba
no parallelism
Ad96el Apr 21, 2024
385d736
Merge branch 'develop' into ag_integration_tests_chopsticks
ntn-x2 Apr 22, 2024
e9a3b76
rename ci step
Ad96el Apr 22, 2024
aaa24cf
Merge branch 'ag_integration_tests_chopsticks' of github.com:KILTprot…
Ad96el Apr 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@
**/node_modules

runtimes/spiritnet/src/xcm_tests/e2e/out

*.db.sqlite*
15 changes: 14 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ clippy-and-docs:
- cargo clippy --all-features --all-targets --locked -- -D warnings
- RUSTDOCFLAGS='-D warnings' cargo doc --all-features --no-deps --locked

fmt:
fmt-rust:
image: paritytech/ci-unified:bullseye-1.70.0
stage: test
script:
Expand All @@ -30,6 +30,19 @@ test-features:
script:
- cargo test --all --all-features --all-targets --locked

integration-tests:
timeout: 15 minutes
image: paritytech/ci-unified:bullseye-1.70.0
stage: test
script:
- cd ./integration-tests/chopsticks
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
- nvm install
- cargo build -p spiritnet-runtime
- yarn --immutable
- yarn lint
- yarn test

# TODO: The try-runtime-cli executable could be built as part of the Docker image directly, saving some time.
test-try-runtime:
parallel:
Expand Down
6 changes: 6 additions & 0 deletions integration-tests/chopsticks/.env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
HYDRADX_WS=
HYDRADX_PORT=
POLKADOT_WS=
POLKADOT_PORT=
SPIRITNET_WS=
SPIRITNET_PORT=
17 changes: 17 additions & 0 deletions integration-tests/chopsticks/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"env": {
"node": true,
"es2021": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint", "prettier"],
"rules": {
"quotes": ["warn", "single"]
}
}
1 change: 1 addition & 0 deletions integration-tests/chopsticks/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.11.0
1 change: 1 addition & 0 deletions integration-tests/chopsticks/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "singleQuote": true, "trailingComma": "es5", "semi": false }
38 changes: 38 additions & 0 deletions integration-tests/chopsticks/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "@kiltprotocol/e2e-tests",
"version": "0.0.1",
"description": "chopsticks integration tests",
"private": "true",
"type": "module",
"repository": "git@github.com:KILTprotocol/kilt-node.git",
"author": "[\"KILT <info@kilt.io>\"]",
"license": "MIT",
"devDependencies": {
"@acala-network/chopsticks": "0.10.0",
"@acala-network/chopsticks-testing": "0.10.0",
"@polkadot/api": "^10.11.2",
"@types/node": "^20.11.30",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"eslint": "^8.0.1",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard-with-typescript": "^43.0.1",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-n": "^15.0.0 || ^16.0.0 ",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.0.0",
"prettier": "^3.2.5",
"ts-node": "^10.9.2",
"tsx": "^4.7.1",
"typescript": "*",
"vitest": "^1.4.0",
"eslint-plugin-jsx-a11y": "^6.8.0"
},
"scripts": {
"lint": "eslint src && prettier --check src",
"lint:fix": "eslint --fix src && prettier --write src",
"clean": "rm -rf ./db && cargo build -p spiritnet-runtime",
"test": "LOG_LEVEL=error vitest --testTimeout=5000 --isolate=true"
}
}
77 changes: 77 additions & 0 deletions integration-tests/chopsticks/src/network/hydraDx.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { setupContext, SetupOption } from '@acala-network/chopsticks-testing'
import type { Config } from './types.js'
import * as SpiritnetConfig from './spiritnet.js'
import { initialBalanceHDX, initialBalanceKILT, toNumber } from '../utils.js'

/// Options used to create the HydraDx context
export const options: SetupOption = {
endpoint: process.env.HYDRADX_WS || ['wss://hydradx-rpc.dwellir.com', 'wss://rpc.hydradx.cloud'],
db: './db/hydradx.db.sqlite',
port: toNumber(process.env.HYDRADX_PORT) || 9001,
}

export const kiltTokenId = 60

/// Sets the [TechnicalCommittee] and [Council] governance to the given accounts
export function setGovernance(addr: string[]) {
return {
TechnicalCommittee: { Members: addr },
Council: { Members: addr },
}
}

/// Assigns the native tokens to an accounts
export function assignNativeTokensToAccounts(addr: string[], balance: bigint = initialBalanceHDX) {
return {
System: {
Account: addr.map((address) => [[address], { providers: 1, data: { free: balance } }]),
},
}
}

/// Assigns KILT tokens to an accounts
export function assignKiltTokensToAccounts(addr: string[], balance: bigint = initialBalanceKILT) {
return {
Tokens: {
Accounts: addr.map((address) => [[address, kiltTokenId], { free: balance }]),
},
}
}

/// Register KILT into HydraDX and allow KILT as payment
export function registerKilt() {
return {
assetRegistry: {
assetLocations: [[[kiltTokenId], { parents: 1, interior: { X1: { Parachain: SpiritnetConfig.paraId } } }]],
assetIds: [[['KILT'], kiltTokenId]],
locationAssets: [[[{ parents: 1, interior: { X1: { Parachain: SpiritnetConfig.paraId } } }], kiltTokenId]],
assets: [
[
[kiltTokenId],
{
name: 'KILT',
assetType: 'Token',
existentialDeposit: 500,
symbol: 'KILT',
decimals: 18,
xcmRateLimit: null,
isSufficient: true,
},
],
],
},
multiTransactionPayment: {
acceptedCurrencies: [[[kiltTokenId], 100_000]],
},
}
}

/// HydraDX ParaId
export const paraId = 2034

/// OmniPool account
export const omnipoolAccount = '7L53bUTBbfuj14UpdCNPwmgzzHSsrsTWBHX5pys32mVWM3C1'

export async function getContext(): Promise<Config> {
return setupContext(options)
}
40 changes: 40 additions & 0 deletions integration-tests/chopsticks/src/network/polkadot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { setupContext, SetupOption } from '@acala-network/chopsticks-testing'
import type { Config } from './types.js'
import { initialBalanceDOT, toNumber } from '../utils.js'

/// Options used to create the HydraDx context
export const options: SetupOption = {
endpoint: process.env.POLKADOT_WS || [
'wss://rpc.polkadot.io',
'wss://polkadot-rpc.dwellir.com',
'wss://rpc.ibp.network/polkadot',
],
db: './db/polkadot.db.sqlite',
port: toNumber(process.env.POLKADOT_PORT) || 9000,
}

/// Assigns the native tokens to an accounts
export function assignNativeTokensToAccounts(addr: string[], balance: bigint = initialBalanceDOT) {
return {
System: {
Account: addr.map((address) => [[address], { providers: 1, data: { free: balance } }]),
},
}
}

export function removeDisputesAndMessageQueues() {
return {
ParasDisputes: {
// those can makes block building super slow
$removePrefix: ['disputes'],
},
Dmp: {
// clear existing dmp to avoid impact test result
$removePrefix: ['downwardMessageQueues'],
},
}
}

export async function getContext(): Promise<Config> {
return setupContext(options)
}
50 changes: 50 additions & 0 deletions integration-tests/chopsticks/src/network/spiritnet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { setupContext, SetupOption } from '@acala-network/chopsticks-testing'
import type { Config } from './types.js'
import { initialBalanceKILT, toNumber } from '../utils.js'

/// Options used to create the Spiritnet context
const options: SetupOption = {
endpoint: process.env.SPIRITNET_WS || 'wss://kilt-rpc.dwellir.com',
db: './db/spiritnet.db.sqlite',
port: toNumber(process.env.SPIRITNET_PORT) || 9002,
wasmOverride: '../../target/debug/wbuild/spiritnet-runtime/spiritnet_runtime.wasm',
// 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.
allowUnresolvedImports: true,
}

/// Assigns the native tokens to an accounts
export function assignNativeTokensToAccounts(addr: string[], balance: bigint = initialBalanceKILT) {
return {
System: {
Account: addr.map((address) => [[address], { providers: 1, data: { free: balance } }]),
},
}
}

/// Sets the [technicalCommittee] and [council] governance to the given accounts
export function setGovernance(addr: string[]) {
return {
technicalCommittee: { Members: addr },
council: { Members: addr },
}
}

/// Sets the [safeXcmVersion] to the given version
export function setSafeXcmVersion(version: number) {
return {
polkadotXcm: {
safeXcmVersion: version,
},
}
}

/// Spiritnet ParaId
export const paraId = 2086

/// The sovereign account of HydraDx in Spiritnet
export const hydraDxSovereignAccount = '4qXPdpioJ6D8cgdeYXaukV2Y2oAQUHaX1VnGhdbSRqJn2CBt'

/// Returns the Spiritnet context for the given options
export async function getContext(): Promise<Config> {
return setupContext(options)
}
3 changes: 3 additions & 0 deletions integration-tests/chopsticks/src/network/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { setupContext } from '@acala-network/chopsticks-testing'

export type Config = Awaited<ReturnType<typeof setupContext>>
53 changes: 53 additions & 0 deletions integration-tests/chopsticks/src/network/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
export function getSiblingLocation(paraId: number) {
return {
parents: 1,
interior: {
X1: { Parachain: paraId },
},
}
}

export function getParentLocation() {
return {
parents: 1,
interior: 'Here',
}
}

export function getAccountLocationV2(addr: string) {
return {
V2: {
parents: 0,
interior: {
X1: {
AccountId32: {
network: 'Any',
id: addr,
},
},
},
},
}
}

export function getAccountLocationV3(addr: string) {
return {
V3: {
parents: 0,
interior: {
X1: {
AccountId32: {
id: addr,
},
},
},
},
}
}

export function getNativeAssetIdLocation(amount: bigint) {
return {
id: { Concrete: { parents: 0, interior: 'Here' } },
fun: { Fungible: amount },
}
}
59 changes: 59 additions & 0 deletions integration-tests/chopsticks/src/tests/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { beforeAll, afterAll } from 'vitest'
import { connectParachains, connectVertical } from '@acala-network/chopsticks'
import { setTimeout } from 'timers/promises'

import * as SpiritnetConfig from '../network/spiritnet.js'
import * as PolkadotConfig from '../network/polkadot.js'
import * as HydraDxConfig from '../network/hydraDx.js'
import type { Config } from '../network/types.js'
import { setStorage } from './utils.js'

export let spiritnetContext: Config
export let hydradxContext: Config
export let polkadotContext: Config

beforeAll(async () => {
spiritnetContext = await SpiritnetConfig.getContext()
hydradxContext = await HydraDxConfig.getContext()
polkadotContext = await PolkadotConfig.getContext()

// Setup network
await connectVertical(polkadotContext.chain, spiritnetContext.chain)
await connectVertical(polkadotContext.chain, hydradxContext.chain)
await connectParachains([spiritnetContext.chain, hydradxContext.chain])

const newBlockConfig = { count: 2 }
// fixes api runtime disconnect warning
await setTimeout(50)
// Perform runtime upgrade and establish xcm connections.
await Promise.all([
polkadotContext.dev.newBlock(newBlockConfig),
spiritnetContext.dev.newBlock(newBlockConfig),
hydradxContext.dev.newBlock(newBlockConfig),
])

console.info('Runtime Upgrade completed')

// set SafeXcmVersion to 3
await setStorage(spiritnetContext, SpiritnetConfig.setSafeXcmVersion(3))

// register Kilt in HydraDX
await setStorage(hydradxContext, HydraDxConfig.registerKilt())
}, 60_000)

afterAll(async () => {
// fixes api runtime disconnect warning
await setTimeout(50)
await Promise.all([spiritnetContext.teardown(), hydradxContext.teardown(), polkadotContext.teardown()])
})

export async function getFreeBalanceSpiritnet(account: string): Promise<bigint> {
const accountInfo = await spiritnetContext.api.query.system.account(account)
return accountInfo.data.free.toBigInt()
}

export async function getFreeBalanceHydraDxKilt(account: string): Promise<bigint> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const accountInfo: any = await hydradxContext.api.query.tokens.accounts(account, HydraDxConfig.kiltTokenId)
return accountInfo.free.toBigInt()
}
Loading