From 5e5c4e41db46baaa790ae0880dc9ab40218dbf3d Mon Sep 17 00:00:00 2001 From: luu-alex Date: Fri, 10 Nov 2023 14:52:15 -0500 Subject: [PATCH 01/11] add script --- package.json | 1 + packages/web3/test/manual/connection.js | 71 +++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 packages/web3/test/manual/connection.js diff --git a/package.json b/package.json index c136d147f66..e56b57814e8 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,7 @@ "test:e2e:mainnet:ws": "./scripts/test-runner.sh mainnet ws", "test:e2e:sepolia:http": "./scripts/test-runner.sh sepolia http", "test:e2e:sepolia:ws": "./scripts/test-runner.sh sepolia ws", + "test:manual":"node ./packages/web3/test/manual/connection.js", "generate:accounts": "node ./scripts/gen_accounts.js", "pre-blackbox": "yarn config set registry http://localhost:4873 && git init && git config --global user.email \"ci@github.com\" && git config --global user.name \"CI\"", "post-blackbox": "./scripts/verdaccio.sh stop", diff --git a/packages/web3/test/manual/connection.js b/packages/web3/test/manual/connection.js new file mode 100644 index 00000000000..8928671882c --- /dev/null +++ b/packages/web3/test/manual/connection.js @@ -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 . +*/ + +const { Web3 } = require('../../'); +const secrets = require('../../../../.secrets.json'); + +let web3; +let attempt = 0; +let intervalId; +let start; +let end; + +// constantly send requests through WS for 10 hours +const sendRequests = () => { + start = new Date(); + console.log("start:",start) + return new Promise((resolve, reject) => { + // send a request in intervals of 10 minutes + intervalId = setInterval( async() => { + try{ + const block = await web3.eth.getBlock() + attempt++; + console.log(block) + console.log("successful calls:", attempt, "has ran for:", attempt*10, "minutes") + if (attempt === 144) { // after 10 hours + clearInterval(intervalId); + resolve(""); + } + } catch (error) { + clearInterval(intervalId); + reject(error); + } + },600000) + }) + +} + +const main = async () => { + + try { + // You will need to set mainnet infura provider + const provider = secrets.MAINNET.WS; + console.log(provider) + web3 = new Web3(provider); + const promise = sendRequests(); + await promise; + end = new Date(); + console.log("websocket test successful") + } catch (e) { + // console.warn("error occured during ws test, on attempt: ", attempt, "program ran for: ", attempt ,"minutes with error: ", e) + } + console.log("start", start) + console.log("end", end) + process.exit(); +} + +main(); \ No newline at end of file From d5d2c680eb6fe4c5955aac500328fc0918467c99 Mon Sep 17 00:00:00 2001 From: luu-alex Date: Fri, 10 Nov 2023 15:07:46 -0500 Subject: [PATCH 02/11] add eslint disable --- packages/web3/test/manual/connection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web3/test/manual/connection.js b/packages/web3/test/manual/connection.js index 8928671882c..1345325aea8 100644 --- a/packages/web3/test/manual/connection.js +++ b/packages/web3/test/manual/connection.js @@ -14,7 +14,7 @@ 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 . */ - +/* eslint-disable */ const { Web3 } = require('../../'); const secrets = require('../../../../.secrets.json'); From b65aefd7df15666a992dad440265bb2f891ce5b6 Mon Sep 17 00:00:00 2001 From: luu-alex Date: Sun, 12 Nov 2023 09:19:34 -0500 Subject: [PATCH 03/11] add details --- packages/web3/test/manual/connection.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/web3/test/manual/connection.js b/packages/web3/test/manual/connection.js index 1345325aea8..77d51f940ae 100644 --- a/packages/web3/test/manual/connection.js +++ b/packages/web3/test/manual/connection.js @@ -44,7 +44,7 @@ const sendRequests = () => { clearInterval(intervalId); reject(error); } - },600000) + },600000) // every 10 minutes }) } @@ -53,8 +53,7 @@ const main = async () => { try { // You will need to set mainnet infura provider - const provider = secrets.MAINNET.WS; - console.log(provider) + const provider = secrets.MAINNET.WS; web3 = new Web3(provider); const promise = sendRequests(); await promise; From 62b411949a0f1ad1ff80da0226c00e30f83387a4 Mon Sep 17 00:00:00 2001 From: luu-alex Date: Mon, 13 Nov 2023 21:50:32 -0500 Subject: [PATCH 04/11] add browser test --- .../test/manual/browser_test/connection.html | 93 +++++++++++++++++++ .../manual/{ => nodejs_test}/connection.js | 0 2 files changed, 93 insertions(+) create mode 100644 packages/web3/test/manual/browser_test/connection.html rename packages/web3/test/manual/{ => nodejs_test}/connection.js (100%) diff --git a/packages/web3/test/manual/browser_test/connection.html b/packages/web3/test/manual/browser_test/connection.html new file mode 100644 index 00000000000..59b4a2442b7 --- /dev/null +++ b/packages/web3/test/manual/browser_test/connection.html @@ -0,0 +1,93 @@ + + + + + + Manual browser tests + + + + + +

Manual browser test - for this test you will need to provide an ws infura endpoint in this html page. This will test the web3js ws provider by sending a request every 10 minutes for 10 hours

+ +

Start time:

+ + +

End Time:

+ + +

Number of requests sent:

+ + +

Has ran for minutes

+ + +

Block number:

+ + +

Result:

+ + + + + + + + diff --git a/packages/web3/test/manual/connection.js b/packages/web3/test/manual/nodejs_test/connection.js similarity index 100% rename from packages/web3/test/manual/connection.js rename to packages/web3/test/manual/nodejs_test/connection.js From 1894d8bb70ce8ea1ea037bdbf514b3f035bb4ee5 Mon Sep 17 00:00:00 2001 From: luu-alex Date: Tue, 14 Nov 2023 10:05:02 -0500 Subject: [PATCH 05/11] fix manual ws test cases --- package.json | 2 +- packages/web3/test/manual/browser_test/connection.html | 9 +++++---- packages/web3/test/manual/nodejs_test/connection.js | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index e56b57814e8..482eae2bee3 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "test:e2e:mainnet:ws": "./scripts/test-runner.sh mainnet ws", "test:e2e:sepolia:http": "./scripts/test-runner.sh sepolia http", "test:e2e:sepolia:ws": "./scripts/test-runner.sh sepolia ws", - "test:manual":"node ./packages/web3/test/manual/connection.js", + "test:manual":"node ./packages/web3/test/manual/nodejs_test/connection.js", "generate:accounts": "node ./scripts/gen_accounts.js", "pre-blackbox": "yarn config set registry http://localhost:4873 && git init && git config --global user.email \"ci@github.com\" && git config --global user.name \"CI\"", "post-blackbox": "./scripts/verdaccio.sh stop", diff --git a/packages/web3/test/manual/browser_test/connection.html b/packages/web3/test/manual/browser_test/connection.html index 59b4a2442b7..b93daa92aeb 100644 --- a/packages/web3/test/manual/browser_test/connection.html +++ b/packages/web3/test/manual/browser_test/connection.html @@ -11,6 +11,8 @@

Manual browser test - for this test you will need to provide an ws infura endpoint in this html page. This will test the web3js ws provider by sending a request every 10 minutes for 10 hours

+ +

Keep dev console open in case of any unintended errors occur

Start time:

@@ -37,7 +39,8 @@ let start; let end; let result; - web3 = new Web3(""); // provide ws infura link + // You will need to set mainnet infura provider + web3 = new Web3(""); // constantly send requests through WS for 10 hours const sendRequests = () => { @@ -60,7 +63,7 @@ document.getElementById("result").innerText = "Error"; reject(error); } - },6000) // every 10 minutes + },60000) // every 10 minutes }) } @@ -68,8 +71,6 @@ const main = async () => { try { - // You will need to set mainnet infura provider - // web3 = new Web3(provider); start = new Date(); document.getElementById("startTime").innerText = start.toTimeString(); document.getElementById("attempts").innerText = attempt.toString(); diff --git a/packages/web3/test/manual/nodejs_test/connection.js b/packages/web3/test/manual/nodejs_test/connection.js index 77d51f940ae..3fc2316f5fe 100644 --- a/packages/web3/test/manual/nodejs_test/connection.js +++ b/packages/web3/test/manual/nodejs_test/connection.js @@ -15,8 +15,8 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ /* eslint-disable */ -const { Web3 } = require('../../'); -const secrets = require('../../../../.secrets.json'); +const { Web3 } = require('../../../'); +const secrets = require('../../../../../.secrets.json'); let web3; let attempt = 0; From 760ab366eda1170c06ea33b605018e0d1292432a Mon Sep 17 00:00:00 2001 From: luu-alex Date: Wed, 15 Nov 2023 10:37:16 -0500 Subject: [PATCH 06/11] add manual tests to stress folder --- package.json | 2 +- .../test/{ => stress}/manual/browser_test/connection.html | 2 +- .../web3/test/{ => stress}/manual/nodejs_test/connection.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename packages/web3/test/{ => stress}/manual/browser_test/connection.html (98%) rename packages/web3/test/{ => stress}/manual/nodejs_test/connection.js (94%) diff --git a/package.json b/package.json index 482eae2bee3..42a50af08f9 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "test:e2e:mainnet:ws": "./scripts/test-runner.sh mainnet ws", "test:e2e:sepolia:http": "./scripts/test-runner.sh sepolia http", "test:e2e:sepolia:ws": "./scripts/test-runner.sh sepolia ws", - "test:manual":"node ./packages/web3/test/manual/nodejs_test/connection.js", + "test:manual":"node ./packages/web3/test/stress/manual/nodejs_test/connection.js", "generate:accounts": "node ./scripts/gen_accounts.js", "pre-blackbox": "yarn config set registry http://localhost:4873 && git init && git config --global user.email \"ci@github.com\" && git config --global user.name \"CI\"", "post-blackbox": "./scripts/verdaccio.sh stop", diff --git a/packages/web3/test/manual/browser_test/connection.html b/packages/web3/test/stress/manual/browser_test/connection.html similarity index 98% rename from packages/web3/test/manual/browser_test/connection.html rename to packages/web3/test/stress/manual/browser_test/connection.html index b93daa92aeb..8ffcfedbaa0 100644 --- a/packages/web3/test/manual/browser_test/connection.html +++ b/packages/web3/test/stress/manual/browser_test/connection.html @@ -5,7 +5,7 @@ Manual browser tests - diff --git a/packages/web3/test/manual/nodejs_test/connection.js b/packages/web3/test/stress/manual/nodejs_test/connection.js similarity index 94% rename from packages/web3/test/manual/nodejs_test/connection.js rename to packages/web3/test/stress/manual/nodejs_test/connection.js index 3fc2316f5fe..c1792530695 100644 --- a/packages/web3/test/manual/nodejs_test/connection.js +++ b/packages/web3/test/stress/manual/nodejs_test/connection.js @@ -15,8 +15,8 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ /* eslint-disable */ -const { Web3 } = require('../../../'); -const secrets = require('../../../../../.secrets.json'); +const { Web3 } = require('../../../../lib/commonjs'); +const secrets = require('../../../../../../.secrets.json'); let web3; let attempt = 0; From 7f75947828a1812a683ff6a2b5f15dfce0538d7d Mon Sep 17 00:00:00 2001 From: luu-alex Date: Mon, 20 Nov 2023 13:46:00 -0500 Subject: [PATCH 07/11] update naming --- package.json | 2 +- .../manual/nodejs_test/{connection.js => long_connection_ws.js} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename packages/web3/test/stress/manual/nodejs_test/{connection.js => long_connection_ws.js} (93%) diff --git a/package.json b/package.json index f1284683080..3e13409e569 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "test:e2e:mainnet:ws": "./scripts/test-runner.sh mainnet ws", "test:e2e:sepolia:http": "./scripts/test-runner.sh sepolia http", "test:e2e:sepolia:ws": "./scripts/test-runner.sh sepolia ws", - "test:manual":"node ./packages/web3/test/stress/manual/nodejs_test/connection.js", + "test:manual:long-connection-ws":"node ./packages/web3/test/stress/manual/nodejs_test/long_connection_ws.js", "generate:accounts": "node ./scripts/gen_accounts.js", "pre-blackbox": "yarn config set registry http://localhost:4873 && git init && git config --global user.email \"ci@github.com\" && git config --global user.name \"CI\"", "post-blackbox": "./scripts/verdaccio.sh stop", diff --git a/packages/web3/test/stress/manual/nodejs_test/connection.js b/packages/web3/test/stress/manual/nodejs_test/long_connection_ws.js similarity index 93% rename from packages/web3/test/stress/manual/nodejs_test/connection.js rename to packages/web3/test/stress/manual/nodejs_test/long_connection_ws.js index c1792530695..9abc2a4e9df 100644 --- a/packages/web3/test/stress/manual/nodejs_test/connection.js +++ b/packages/web3/test/stress/manual/nodejs_test/long_connection_ws.js @@ -60,7 +60,7 @@ const main = async () => { end = new Date(); console.log("websocket test successful") } catch (e) { - // console.warn("error occured during ws test, on attempt: ", attempt, "program ran for: ", attempt ,"minutes with error: ", e) + console.warn("error occured during ws test, on attempt: ", attempt, "program ran for: ", attempt ,"minutes with error: ", e) } console.log("start", start) console.log("end", end) From 2ec48526661116d6064865cb93c605b54def8284 Mon Sep 17 00:00:00 2001 From: luu-alex Date: Mon, 20 Nov 2023 13:54:47 -0500 Subject: [PATCH 08/11] add test:manual script --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e9ff2250abf..e9198e878e6 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,7 @@ yarn add web3 | test | Uses `jest` to run unit tests in each package | | test:integration | Uses `jest` to run tests under `/test/integration` in each package | | test:unit | Uses `jest` to run tests under `/test/unit` in each package | +| test:manual | Runs manual tests under `test/stress` in the web3 package | [npm-url]: https://npmjs.org/package/web3 [downloads-image]: https://img.shields.io/npm/dm/web3?label=npm%20downloads From 95394758e1759e170e01a116caa0ff57c0319a90 Mon Sep 17 00:00:00 2001 From: luu-alex Date: Mon, 20 Nov 2023 13:57:12 -0500 Subject: [PATCH 09/11] rename folder --- package.json | 2 +- .../long_ws_tests}/browser_test/connection.html | 0 .../long_ws_tests}/nodejs_test/long_connection_ws.js | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename packages/web3/test/{stress/manual => manual/long_ws_tests}/browser_test/connection.html (100%) rename packages/web3/test/{stress/manual => manual/long_ws_tests}/nodejs_test/long_connection_ws.js (100%) diff --git a/package.json b/package.json index 70242a8c482..94df18c3fce 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "test:e2e:mainnet:ws": "./scripts/test-runner.sh mainnet ws", "test:e2e:sepolia:http": "./scripts/test-runner.sh sepolia http", "test:e2e:sepolia:ws": "./scripts/test-runner.sh sepolia ws", - "test:manual:long-connection-ws":"node ./packages/web3/test/stress/manual/nodejs_test/long_connection_ws.js", + "test:manual:long-connection-ws":"node ./packages/web3/test/manual/long_ws_tests/nodejs_test/long_connection_ws.js", "generate:accounts": "node ./scripts/gen_accounts.js", "pre-blackbox": "yarn config set registry http://localhost:4873 && git init && git config --global user.email \"ci@github.com\" && git config --global user.name \"CI\"", "post-blackbox": "./scripts/verdaccio.sh stop", diff --git a/packages/web3/test/stress/manual/browser_test/connection.html b/packages/web3/test/manual/long_ws_tests/browser_test/connection.html similarity index 100% rename from packages/web3/test/stress/manual/browser_test/connection.html rename to packages/web3/test/manual/long_ws_tests/browser_test/connection.html diff --git a/packages/web3/test/stress/manual/nodejs_test/long_connection_ws.js b/packages/web3/test/manual/long_ws_tests/nodejs_test/long_connection_ws.js similarity index 100% rename from packages/web3/test/stress/manual/nodejs_test/long_connection_ws.js rename to packages/web3/test/manual/long_ws_tests/nodejs_test/long_connection_ws.js From a7e7cdca6c78795d17ef2ed99e4b913875abbcc2 Mon Sep 17 00:00:00 2001 From: luu-alex Date: Mon, 20 Nov 2023 14:30:22 -0500 Subject: [PATCH 10/11] update script --- README.md | 2 +- package.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e9198e878e6..4baf220afb3 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ yarn add web3 | test | Uses `jest` to run unit tests in each package | | test:integration | Uses `jest` to run tests under `/test/integration` in each package | | test:unit | Uses `jest` to run tests under `/test/unit` in each package | -| test:manual | Runs manual tests under `test/stress` in the web3 package | +| test:manual | Runs manual tests under `test/manual` in the web3 package | [npm-url]: https://npmjs.org/package/web3 [downloads-image]: https://img.shields.io/npm/dm/web3?label=npm%20downloads diff --git a/package.json b/package.json index 94df18c3fce..d8122891087 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,6 @@ "test:e2e:mainnet:ws": "./scripts/test-runner.sh mainnet ws", "test:e2e:sepolia:http": "./scripts/test-runner.sh sepolia http", "test:e2e:sepolia:ws": "./scripts/test-runner.sh sepolia ws", - "test:manual:long-connection-ws":"node ./packages/web3/test/manual/long_ws_tests/nodejs_test/long_connection_ws.js", "generate:accounts": "node ./scripts/gen_accounts.js", "pre-blackbox": "yarn config set registry http://localhost:4873 && git init && git config --global user.email \"ci@github.com\" && git config --global user.name \"CI\"", "post-blackbox": "./scripts/verdaccio.sh stop", @@ -89,6 +88,8 @@ "test:manual:stress:data": "packages/web3/test/stress/start.sh", "test:manual:stress:validation": "npx ts-node packages/web3/test/stress/validator.ts", "test:manual:stress": "yarn test:manual:stress:data && yarn test:manual:stress:validation", + "test:manual:long-connection-ws":"node ./packages/web3/test/manual/long_ws_tests/nodejs_test/long_connection_ws.js", + "test:manual":"yarn test:manual:stress && yarn test:manual:long-connection-ws", "husky:install": "husky install", "husky:uninstall": "husky uninstall", "postinstall": "yarn build", From fef8fe22fc124286633a2fa85376074715fdfa13 Mon Sep 17 00:00:00 2001 From: luu-alex Date: Mon, 20 Nov 2023 14:31:31 -0500 Subject: [PATCH 11/11] add html comment --- .../web3/test/manual/long_ws_tests/browser_test/connection.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web3/test/manual/long_ws_tests/browser_test/connection.html b/packages/web3/test/manual/long_ws_tests/browser_test/connection.html index 8ffcfedbaa0..8b3c8c346fd 100644 --- a/packages/web3/test/manual/long_ws_tests/browser_test/connection.html +++ b/packages/web3/test/manual/long_ws_tests/browser_test/connection.html @@ -11,7 +11,7 @@

Manual browser test - for this test you will need to provide an ws infura endpoint in this html page. This will test the web3js ws provider by sending a request every 10 minutes for 10 hours

- +

Have this html test open in a browser of your choice

Keep dev console open in case of any unintended errors occur

Start time: