Skip to content

chore: add reliability tests package with longevity tests #2361

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/test-reliability.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Run Reliability Test

on:
workflow_dispatch:
push:
branches:
- "chore/longevity-tests"

env:
NODE_JS: "20"

jobs:
node:
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
checks: write
steps:
- uses: actions/checkout@v3
with:
repository: waku-org/js-waku

- name: Remove unwanted software
uses: ./.github/actions/prune-vm

- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_JS }}

- uses: ./.github/actions/npm

- run: npm run build:esm

- name: Run tests
timeout-minutes: 150
run: npm run test:longevity
55 changes: 55 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"packages/sds",
"packages/rln",
"packages/tests",
"packages/reliability-tests",
"packages/browser-tests",
"packages/build-utils",
"packages/react-native-polyfills"
Expand All @@ -33,6 +34,7 @@
"test": "NODE_ENV=test npm run test --workspaces --if-present",
"test:browser": "NODE_ENV=test npm run test:browser --workspaces --if-present",
"test:node": "NODE_ENV=test npm run test:node --workspaces --if-present",
"test:longevity": "npm --prefix packages/reliability-tests run test:longevity",
"proto": "npm run proto --workspaces --if-present",
"deploy": "node ci/deploy.js",
"doc": "run-s doc:*",
Expand Down
12 changes: 12 additions & 0 deletions packages/reliability-tests/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
parserOptions: {
tsconfigRootDir: __dirname,
project: "./tsconfig.dev.json"
},
rules: {
"@typescript-eslint/no-non-null-assertion": "off"
},
globals: {
process: true
}
};
13 changes: 13 additions & 0 deletions packages/reliability-tests/.mocharc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const config = {
extension: ['ts'],
require: ['ts-node/register', 'isomorphic-fetch'],
loader: 'ts-node/esm',
'node-option': [
'experimental-specifier-resolution=node',
'loader=ts-node/esm'
],
exit: true,
retries: 0
};

module.exports = config;
26 changes: 26 additions & 0 deletions packages/reliability-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Reliability Tests

This package contains reliability and stability tests for the [js-waku](https://github.com/waku-org/js-waku) project.

These tests are designed to run realistic message scenarios in loops over extended periods, helping identify edge cases, memory leaks, network inconsistencies, or message delivery issues that may appear over time.

## 📄 Current Tests

### `longevity.spec.ts`

This is the first test in the suite. It runs a js-waku<->nwaku filter scenario in a loop for 2 hours, sending and receiving messages continuously.

The test records:
- Message ID
- Timestamp
- Send/receive status
- Any errors during transmission

At the end, a summary report is printed and any failures cause the test to fail.

## 🚀 How to Run

From the **project root**:

```bash
npm run test:longevity
92 changes: 92 additions & 0 deletions packages/reliability-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"name": "@waku/reliability-tests",
"private": true,
"version": "0.0.1",
"description": "Waku reliability tests",
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}
},
"type": "module",
"author": "Waku Team",
"homepage": "https://github.com/waku-org/js-waku/tree/master/packages/reliability-tests#readme",
"repository": {
"type": "git",
"url": "https://github.com/waku-org/js-waku.git"
},
"bugs": {
"url": "https://github.com/waku-org/js-waku/issues"
},
"license": "MIT OR Apache-2.0",
"keywords": [
"waku",
"decentralized",
"secure",
"communication",
"web3",
"ethereum",
"dapps",
"privacy"
],
"scripts": {
"build": "run-s build:**",
"build:esm": "tsc",
"fix": "run-s fix:*",
"fix:lint": "eslint src tests --fix",
"check": "run-s check:*",
"check:lint": "eslint src tests",
"check:spelling": "cspell \"{README.md,{tests,src}/**/*.ts}\"",
"check:tsc": "tsc -p tsconfig.dev.json",
"test:longevity": "NODE_ENV=test node ./src/run-tests.js tests/longevity.spec.ts",
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build"
},
"engines": {
"node": ">=20"
},
"dependencies": {
"@libp2p/interface-compliance-tests": "^6.0.1",
"@libp2p/peer-id": "^5.0.1",
"@waku/core": "*",
"@waku/enr": "*",
"@waku/interfaces": "*",
"@waku/utils": "*",
"app-root-path": "^3.1.0",
"chai-as-promised": "^7.1.1",
"debug": "^4.3.4",
"dockerode": "^4.0.2",
"fast-check": "^3.19.0",
"p-retry": "^6.1.0",
"p-timeout": "^6.1.0",
"portfinder": "^1.0.32",
"sinon": "^18.0.0",
"tail": "^2.2.6"
},
"devDependencies": {
"@libp2p/bootstrap": "^11.0.1",
"@libp2p/crypto": "^5.0.1",
"@types/chai": "^4.3.11",
"@types/dockerode": "^3.3.19",
"@types/mocha": "^10.0.6",
"@types/sinon": "^17.0.3",
"@types/tail": "^2.2.3",
"@waku/discovery": "*",
"@waku/message-encryption": "*",
"@waku/relay": "*",
"@waku/sdk": "*",
"allure-commandline": "^2.27.0",
"allure-mocha": "^2.9.2",
"chai": "^4.3.10",
"cspell": "^8.6.1",
"datastore-core": "^10.0.2",
"debug": "^4.3.4",
"interface-datastore": "^8.2.10",
"libp2p": "2.1.8",
"mocha": "^10.3.0",
"mocha-multi-reporters": "^1.5.1",
"npm-run-all": "^4.1.5"
}
}
50 changes: 50 additions & 0 deletions packages/reliability-tests/src/run-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { exec, spawn } from "child_process";
import { promisify } from "util";

const execAsync = promisify(exec);

const WAKUNODE_IMAGE = process.env.WAKUNODE_IMAGE || "wakuorg/nwaku:v0.35.1";

async function main() {
try {
await execAsync(`docker inspect ${WAKUNODE_IMAGE}`);
console.log(`Using local image ${WAKUNODE_IMAGE}`);
} catch (error) {
console.log(`Pulling image ${WAKUNODE_IMAGE}`);
await execAsync(`docker pull ${WAKUNODE_IMAGE}`);
console.log("Image pulled");
}

const mochaArgs = [
"mocha",
"--require",
"ts-node/register",
"--project",
"./tsconfig.dev.json",
...process.argv.slice(2)
];

// Run mocha tests
const mocha = spawn("npx", mochaArgs, {
stdio: "inherit",
env: {
...process.env,
NODE_ENV: "test"
}
});

mocha.on("error", (error) => {
console.log(`Error running mocha tests: ${error.message}`);
process.exit(1);
});

mocha.on("exit", (code) => {
console.log(`Mocha tests exited with code ${code}`);
process.exit(code || 0);
});
}

main().catch((error) => {
console.log(error);
process.exit(1);
});
Loading
Loading