Skip to content

Commit

Permalink
manually increase blocks for hydradx
Browse files Browse the repository at this point in the history
  • Loading branch information
Chralt98 committed Dec 20, 2023
1 parent 3ec7913 commit abe7c7c
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 12 deletions.
2 changes: 1 addition & 1 deletion integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
32 changes: 24 additions & 8 deletions integration-tests/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
},
});
},
Expand Down

0 comments on commit abe7c7c

Please sign in to comment.