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": "packages/web3/test/stress/start.sh",
"test:stress:validation": "node packages/web3/test/stress/validator.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.

71 changes: 71 additions & 0 deletions packages/web3/test/stress/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
This file is part of web3.js.

web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/

/* eslint-disable */
const { Web3 } = require('../../lib/commonjs');
const { IpcProvider } = require('../../../web3-providers-ipc/lib/commonjs');
const accounts = require('../../../../scripts/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}]`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here as shared in #6595 (comment)

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 packages/web3/test/stress/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 ./packages/web3/test/stress/index.js

export WEB3_SYSTEM_TEST_PROVIDER=ws://127.0.0.1:8545
node ./packages/web3/test/stress/index.js

./scripts/geth_binary.sh stop
Loading