From abe7c7cadf3b3028971de1dd8d47585ef8ef148a Mon Sep 17 00:00:00 2001 From: Chralt98 Date: Wed, 20 Dec 2023 17:13:01 +0100 Subject: [PATCH] manually increase blocks for hydradx --- integration-tests/README.md | 2 +- integration-tests/package.json | 3 +- integration-tests/pnpm-lock.yaml | 32 ++++++++++++----- .../test-chopsticks-runtime-upgrade.ts | 36 +++++++++++++++++-- 4 files changed, 61 insertions(+), 12 deletions(-) diff --git a/integration-tests/README.md b/integration-tests/README.md index 5d888fb3d..fc44e35bf 100644 --- a/integration-tests/README.md +++ b/integration-tests/README.md @@ -36,7 +36,7 @@ You should have installed `python` for using `sqlite3` and then used `pnpm rebui Useful for integration testing: - `./integration-tests/scripts/deploy_zombienet.sh` - Deploy a local relay-parachain network for zombienet. -- `pnpm chopsticks xcm -r polkadot -p hydradx -p ./configs/zeitgeist.yml` - Deploy a local relay-parachain fork network via chopsticks to test XCM. +- `pnpm chopsticks xcm -r polkadot -p ./configs/hydradx.yml -p ./configs/zeitgeist.yml` - Deploy a local relay-parachain fork network via chopsticks to test XCM. - `./integration-tests/scripts/deploy_zombienet.sh --test` - Run ZNDSL zombienet tests on a local relay-parachain network. - `pnpm exec moonwall test chopsticks_zeitgeist_hydra_xcm_tests` - XCM Tests from Zeitgeist to HydraDX. - `pnpm exec moonwall test zombienet_zeitgeist_upgrade` - Test Zeitgeist runtime upgrade on zombienet for the local network. diff --git a/integration-tests/package.json b/integration-tests/package.json index 1ff61eb73..4eeda2b35 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -4,7 +4,8 @@ "@polkadot/keyring": "^12.6.1", "@polkadot/util-crypto": "^12.6.1", "sqlite3": "^5.1.6", - "typescript": "^5.2.2" + "typescript": "^5.2.2", + "ws": "^8.15.1" }, "devDependencies": { "@acala-network/chopsticks": "0.9.3", diff --git a/integration-tests/pnpm-lock.yaml b/integration-tests/pnpm-lock.yaml index 3678342b0..12e20afed 100644 --- a/integration-tests/pnpm-lock.yaml +++ b/integration-tests/pnpm-lock.yaml @@ -17,6 +17,9 @@ dependencies: typescript: specifier: ^5.2.2 version: 5.3.3 + ws: + specifier: ^8.15.1 + version: 8.15.1 devDependencies: '@acala-network/chopsticks': @@ -123,7 +126,7 @@ packages: js-yaml: 4.1.0 jsondiffpatch: 0.5.0 lodash: 4.17.21 - ws: 8.14.2 + ws: 8.15.1 yargs: 17.7.2 zod: 3.22.4 transitivePeerDependencies: @@ -1071,7 +1074,7 @@ packages: dependencies: '@polkadot/x-global': 12.6.1 tslib: 2.6.2 - ws: 8.14.2 + ws: 8.15.1 transitivePeerDependencies: - bufferutil - utf-8-validate @@ -3081,12 +3084,12 @@ packages: readable-stream: 3.6.2 dev: true - /isomorphic-ws@5.0.0(ws@8.14.2): + /isomorphic-ws@5.0.0(ws@8.15.1): resolution: {integrity: sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw==} peerDependencies: ws: '*' dependencies: - ws: 8.14.2 + ws: 8.15.1 dev: true /isows@1.0.3(ws@8.13.0): @@ -3137,7 +3140,7 @@ packages: whatwg-encoding: 3.1.1 whatwg-mimetype: 4.0.0 whatwg-url: 14.0.0 - ws: 8.14.2 + ws: 8.15.1 xml-name-validator: 5.0.0 transitivePeerDependencies: - bufferutil @@ -3167,6 +3170,7 @@ packages: chalk: 3.0.0 diff-match-patch: 1.0.5 dev: true + bundledDependencies: [] /jsonfile@6.1.0: resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==} @@ -4348,7 +4352,7 @@ packages: resolution: {integrity: sha512-VAOBqEen6vises36/zgrmAT1GWk2qE3X8AGnO7lmQFdskbKx8EovnwS22rtPAG+Y1Rk23/S22kDJUdPANyPkBA==} requiresBuild: true dependencies: - ws: 8.14.2 + ws: 8.15.1 transitivePeerDependencies: - bufferutil - utf-8-validate @@ -5290,11 +5294,11 @@ packages: engines: {node: '>=14', npm: '>=6.12.0'} dependencies: '@types/ws': 8.5.3 - isomorphic-ws: 5.0.0(ws@8.14.2) + isomorphic-ws: 5.0.0(ws@8.15.1) web3-errors: 1.1.4 web3-types: 1.3.1 web3-utils: 4.1.0 - ws: 8.14.2 + ws: 8.15.1 transitivePeerDependencies: - bufferutil - utf-8-validate @@ -5504,6 +5508,18 @@ packages: optional: true dev: true + /ws@8.15.1: + resolution: {integrity: sha512-W5OZiCjXEmk0yZ66ZN82beM5Sz7l7coYxpRkzS+p9PP+ToQry8szKh+61eNktr7EA9DOwvFGhfC605jDHbP6QQ==} + engines: {node: '>=10.0.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: '>=5.0.2' + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + /ws@8.5.0: resolution: {integrity: sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==} engines: {node: '>=10.0.0'} diff --git a/integration-tests/tests/rt-upgrade-chopsticks/test-chopsticks-runtime-upgrade.ts b/integration-tests/tests/rt-upgrade-chopsticks/test-chopsticks-runtime-upgrade.ts index 83e3e2c69..702b3c4f3 100644 --- a/integration-tests/tests/rt-upgrade-chopsticks/test-chopsticks-runtime-upgrade.ts +++ b/integration-tests/tests/rt-upgrade-chopsticks/test-chopsticks-runtime-upgrade.ts @@ -4,6 +4,7 @@ import { MoonwallContext, beforeAll, describeSuite, expect } from "@moonwall/cli import { generateKeyringPair } from "@moonwall/util"; import { KeyringPair } from "@moonwall/util"; import { ApiPromise, Keyring } from "@polkadot/api"; +import WebSocket from 'ws'; const MAX_BALANCE_TRANSFER_TRIES = 5; const ZEITGEIST_TOKENS_INDEX = 12; @@ -134,10 +135,41 @@ describeSuite({ // Reported Bug here https://github.com/Moonsong-Labs/moonwall/issues/343 // use a workaround for creating a block - // TODO create block somehow manually using chopsticks + const blocksToRun = 2; + const currentHeight = (await hydradxParaApi.rpc.chain.getBlock()).block.header.number.toNumber(); + const newBlockPromise = new Promise((resolve, reject) => { + // ws://127.0.0.1:8001 represents the HydraDXPara endpoint + const ws = new WebSocket('ws://127.0.0.1:8001'); + + ws.on('open', function open() { + const message = { + jsonrpc: "2.0", + id: 1, + method: "dev_newBlock", + params: [{ to: currentHeight + blocksToRun }] + }; + + ws.send(JSON.stringify(message)); + }); + + ws.on('message', async function message(data) { + const dataObj = JSON.parse(data.toString()); + log('Received message:', dataObj); + resolve(dataObj.result); + }); + + ws.on('error', function error(error) { + log('Error:', error.toString()); + reject(error); + }); + }); + + const blockHash = await newBlockPromise; + const newHeight = (await hydradxParaApi.rpc.chain.getBlock()).block.header.number.toNumber(); + expect(newHeight - currentHeight).to.be.equal(blocksToRun + 1); const hydradxBalanceAfter = (await hydradxParaApi.query.tokens.accounts(bob.address, ZEITGEIST_TOKENS_INDEX)).free.toBigInt(); - // expect(hydradxBalanceBefore < hydradxBalanceAfter).to.be.true; + expect(hydradxBalanceBefore < hydradxBalanceAfter).to.be.true; }, }); },