From a34630535ae914a3a8a9b178034da97fe14aeae5 Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Tue, 5 Dec 2023 10:58:55 +0100 Subject: [PATCH] flood setup --- .gitignore | 3 +++ docker-compose.yml | 1 + package.json | 5 ++++- scripts/flood.ts | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 scripts/flood.ts diff --git a/.gitignore b/.gitignore index 8ae91d088..3ddd845c5 100644 --- a/.gitignore +++ b/.gitignore @@ -70,3 +70,6 @@ jspm_packages/ dist lib *.tsbuildinfo + +flood +flood-result diff --git a/docker-compose.yml b/docker-compose.yml index 2c1a050da..e7084d9af 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -118,6 +118,7 @@ services: # ------------------------------------ # mandala-node: image: ghcr.io/acalanetwork/mandala-node:sha-37d9e36 + platform: linux/amd64 ports: - 9944:9944 healthcheck: diff --git a/package.json b/package.json index 0e035bfe8..3ad9a7295 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,10 @@ "e2e:truffle": "yarn start:eth-rpc-adapter-subql; cd examples/truffle-tutorials; yarn install --immutable; yarn test:mandala", "e2e:hardhat": "yarn start:eth-rpc-adapter; cd examples/hardhat-tutorials; yarn install --immutable; yarn test:mandala", "bump": "yarn workspaces foreach -vit --include '@acala-network/*' --exclude '@acala-network/evm-subql' version", - "postinstall": "husky install" + "postinstall": "husky install", + "build-bodhi-runner": "docker build . -t bodhi-runner -f docker/bodhi-runner.Dockerfile", + "flood:setup": "yarn build-bodhi-runner; yarn start:eth-rpc-adapter-subql; yarn e2e:feed-tx; yarn e2e:feed-tx-2; yarn e2e:waffle", + "flood": "npx ts-node scripts/flood.ts" }, "devDependencies": { "@swc/core": "^1.3.56", diff --git a/scripts/flood.ts b/scripts/flood.ts new file mode 100644 index 000000000..9b40408d6 --- /dev/null +++ b/scripts/flood.ts @@ -0,0 +1,49 @@ +#!/bin/env node + +import { execSync } from 'child_process'; +import { existsSync } from 'fs' + +(async () => { + // set max block number + const head = await fetch('http://localhost:8545', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + jsonrpc: "2.0", + id: 1, + method: "eth_getBlockByNumber", + params: ["latest", false] + }) + }).then(res => res.json()); + + const latestBlock = Number(head.result.number); + console.log(`Latest block: ${latestBlock}`); + + process.env.MAX_BLOCK_NUMBER = latestBlock.toString(); + + if (!existsSync('flood')) { + execSync('git clone --branch acala-bodhi --depth 0 git@github.com:ermalkaleci/flood.git'); + } + + const tests = [ + "eth_call", + "eth_getBalance", + "eth_getBlockByNumber", + "eth_getCode", + "eth_getLogs", + "eth_getStorageAt", + "eth_getTransactionByHash", + "eth_getTransactionCount", + "eth_getTransactionReceipt", + ]; + + for (const test of tests) { + execSync(`cd flood; python3 -m flood ${test} http://localhost:8545 -o ../flood-result/${test} --deep-check`, { + stdio: 'inherit', + env: process.env + }); + await new Promise(resolve => setTimeout(resolve, 10_000)); + } +})(); \ No newline at end of file