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

Stress Tests 2 - QA Tests #6583

Merged
merged 17 commits into from
Nov 20, 2023
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
"test:blackbox:geth:ws": "yarn pre-blackbox && yarn geth:start:background && ./scripts/verdaccio.sh startBackgroundAndPublish && lerna run test:blackbox:geth:ws --stream && yarn post-blackbox:geth",
"test:blackbox:infura:http": "yarn pre-blackbox && ./scripts/verdaccio.sh startBackgroundAndPublish && lerna run test:blackbox:infura:http --stream && yarn post-blackbox",
"test:blackbox:infura:ws": "yarn pre-blackbox && ./scripts/verdaccio.sh startBackgroundAndPublish && lerna run test:blackbox:infura:ws --stream && yarn post-blackbox",
"test:stress:data": "scripts/stressTests/data/start.sh",
"test:stress:validation": "node ./scripts/stressTests/validation/index.js",
"test:stress": "yarn test:stress:data && yarn test:stress:validation",
"husky:install": "husky install",
"husky:uninstall": "husky uninstall",
"postinstall": "yarn build",
Expand Down
184 changes: 0 additions & 184 deletions packages/web3-validator/test/unit/load.test.ts

This file was deleted.

17 changes: 15 additions & 2 deletions scripts/geth_binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,29 @@ start() {
download
if [ -z "${ORIGARGS[1]}" ]; then
echo "Starting geth..."
echo "geth --ipcpath $IPC_PATH --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev --mine --dev.period=0 "
echo "geth --ipcpath $IPC_PATH --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev --mine --dev.period=0"
${TMP_FOLDER}/geth --ipcpath $IPC_PATH --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev --mine --dev.period=0 --rpc.enabledeprecatedpersonal
else
echo "Starting geth..."
echo "geth --ipcpath $IPC_PATH --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev --mine --dev.period=0 &>/dev/null &"
echo "geth --ipcpath $IPC_PATH --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev --mine --dev.period=0 &>/dev/null &"
${TMP_FOLDER}/geth --ipcpath $IPC_PATH --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev --mine --dev.period=0 --rpc.enabledeprecatedpersonal &>/dev/null &
echo "Waiting for geth..."
npx wait-port -t 10000 "$WEB3_SYSTEM_TEST_PORT"
fi
}

startStress() {
download

echo "Starting geth..."
echo "geth --ipcpath $IPC_PATH --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev --mine --dev.period=0 --dev.gaslimit 9000000000000000 --rpc.txfeecap=1000000 &>/dev/null &"
${TMP_FOLDER}/geth --ipcpath $IPC_PATH --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev --mine --dev.period=0 --rpc.enabledeprecatedpersonal --dev.gaslimit 9000000000000000 --rpc.txfeecap=1000000 &>/dev/null &
echo "Waiting for geth..."
npx wait-port -t 10000 "$WEB3_SYSTEM_TEST_PORT"

}


startSync() {
download

Expand All @@ -95,6 +107,7 @@ stop() {
}

case $1 in
stressStart) startStress ;;
syncStart) startSync ;;
syncStop) syncStop ;;
start) start ;;
Expand Down
53 changes: 53 additions & 0 deletions scripts/stressTests/data/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const { Web3 } = require('../../../packages/web3');
avkos marked this conversation as resolved.
Show resolved Hide resolved
const { IpcProvider } = require('../../../packages/web3-providers-ipc');
const accounts = require('../../accounts.json');
const contractData = require('../../../fixtures/build/Basic.json');

const DATA_AMOUNT = 50 * 1024; // 50 kB

const sendAndGetData = async (web3, i) => {
const sendOptions = { from: accounts[i].address };
const deployOptions = {
data: contractData.evm.bytecode.object,
arguments: [123, ''],
gasPrice: await web3.eth.getGasPrice(),
gas: BigInt(9000000000000),
gasLimit: BigInt(9000000000000),
type: BigInt(0),
};
const c = new web3.eth.Contract(contractData.abi);
const contract = await c.deploy(deployOptions).send(sendOptions);

console.time(`Send huge data [${i}]`);
const receipt = await contract.methods
.setValues(1, 'A'.repeat(DATA_AMOUNT), true)
.send({ from: accounts[i].address });
console.timeLog(`Send huge data [${i}]`, receipt.transactionHash);

console.time(`Get huge data [${i}]`);
await contract.methods.getStringValue().call();
console.timeLog(`Get huge data [${i}]`);
};

const test = async () => {
const providerString = process.env.WEB3_SYSTEM_TEST_PROVIDER;
console.log(`Start test with provider: ${providerString}`);
const provider = providerString.includes('ipc')
? new IpcProvider(providerString)
: new Web3.providers.WebsocketProvider(providerString);
const web3 = new Web3(provider);

for (const a of accounts) {
const acc = web3.eth.accounts.privateKeyToAccount(a.privateKey);
web3.eth.accounts.wallet.add(acc);
}

const prs = [];
for (let i = 0; i < 15; i++) {
prs.push(sendAndGetData(web3, i));
}
await Promise.all(prs);
web3.provider.disconnect();
};

test().catch(console.error);
16 changes: 16 additions & 0 deletions scripts/stressTests/data/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
. scripts/env.sh

export WEB3_SYSTEM_TEST_BACKEND="geth"

./scripts/geth_binary.sh stressStart

yarn generate:accounts

export WEB3_SYSTEM_TEST_PROVIDER=$IPC_PATH
node ./scripts/stressTests/data/index.js

export WEB3_SYSTEM_TEST_PROVIDER=ws://127.0.0.1:8545
node ./scripts/stressTests/data/index.js

./scripts/geth_binary.sh stop
Loading
Loading