chore: test agains Fleets and add optional tests (#1432)

* test Prod and Test fleets in CI

* compute predefined nodes once

* remove async

* add optional test step

* fix command
This commit is contained in:
Sasha 2023-08-07 10:27:16 +02:00 committed by GitHub
parent af5d613e47
commit 75808ffc9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 137 additions and 111 deletions

View File

@ -85,6 +85,23 @@ jobs:
name: nwaku-logs name: nwaku-logs
path: packages/tests/log/ path: packages/tests/log/
node_optional:
runs-on: ubuntu-latest
env:
WAKUNODE_IMAGE: "statusteam/nim-waku:v0.18.0"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_JS }}
- uses: ./.github/actions/npm
- run: npm run build:esm
- run: npm run test:optional --workspace=@waku/tests
env:
DEBUG: ""
node_with_go_waku_master: node_with_go_waku_master:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:

120
package-lock.json generated
View File

@ -27559,13 +27559,13 @@
}, },
"packages/core": { "packages/core": {
"name": "@waku/core", "name": "@waku/core",
"version": "0.0.21", "version": "0.0.22",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"dependencies": { "dependencies": {
"@noble/hashes": "^1.3.0", "@noble/hashes": "^1.3.0",
"@waku/interfaces": "0.0.16", "@waku/interfaces": "0.0.17",
"@waku/proto": "0.0.5", "@waku/proto": "0.0.5",
"@waku/utils": "0.0.9", "@waku/utils": "0.0.10",
"debug": "^4.3.4", "debug": "^4.3.4",
"it-all": "^3.0.2", "it-all": "^3.0.2",
"it-length-prefixed": "^9.0.1", "it-length-prefixed": "^9.0.1",
@ -27630,13 +27630,13 @@
}, },
"packages/dns-discovery": { "packages/dns-discovery": {
"name": "@waku/dns-discovery", "name": "@waku/dns-discovery",
"version": "0.0.15", "version": "0.0.16",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"dependencies": { "dependencies": {
"@libp2p/interface-peer-discovery": "^2.0.0", "@libp2p/interface-peer-discovery": "^2.0.0",
"@libp2p/interfaces": "^3.3.2", "@libp2p/interfaces": "^3.3.2",
"@waku/enr": "0.0.15", "@waku/enr": "0.0.16",
"@waku/utils": "0.0.9", "@waku/utils": "0.0.10",
"debug": "^4.3.4", "debug": "^4.3.4",
"dns-query": "^0.11.2", "dns-query": "^0.11.2",
"hi-base32": "^0.5.1", "hi-base32": "^0.5.1",
@ -27653,7 +27653,7 @@
"@rollup/plugin-node-resolve": "^15.0.2", "@rollup/plugin-node-resolve": "^15.0.2",
"@types/chai": "^4.3.4", "@types/chai": "^4.3.4",
"@waku/build-utils": "*", "@waku/build-utils": "*",
"@waku/interfaces": "0.0.16", "@waku/interfaces": "0.0.17",
"chai": "^4.3.7", "chai": "^4.3.7",
"cspell": "^6.31.1", "cspell": "^6.31.1",
"karma": "^6.4.1", "karma": "^6.4.1",
@ -27685,7 +27685,7 @@
}, },
"packages/enr": { "packages/enr": {
"name": "@waku/enr", "name": "@waku/enr",
"version": "0.0.15", "version": "0.0.16",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"dependencies": { "dependencies": {
"@ethersproject/rlp": "^5.7.0", "@ethersproject/rlp": "^5.7.0",
@ -27693,7 +27693,7 @@
"@libp2p/peer-id": "^2.0.4", "@libp2p/peer-id": "^2.0.4",
"@multiformats/multiaddr": "^12.0.0", "@multiformats/multiaddr": "^12.0.0",
"@noble/secp256k1": "^1.7.1", "@noble/secp256k1": "^1.7.1",
"@waku/utils": "0.0.9", "@waku/utils": "0.0.10",
"debug": "^4.3.4", "debug": "^4.3.4",
"js-sha3": "^0.8.0" "js-sha3": "^0.8.0"
}, },
@ -27707,7 +27707,7 @@
"@types/chai": "^4.3.4", "@types/chai": "^4.3.4",
"@types/mocha": "^10.0.1", "@types/mocha": "^10.0.1",
"@waku/build-utils": "*", "@waku/build-utils": "*",
"@waku/interfaces": "0.0.16", "@waku/interfaces": "0.0.17",
"chai": "^4.3.7", "chai": "^4.3.7",
"cspell": "^6.31.1", "cspell": "^6.31.1",
"karma": "^6.4.1", "karma": "^6.4.1",
@ -27730,7 +27730,7 @@
}, },
"packages/interfaces": { "packages/interfaces": {
"name": "@waku/interfaces", "name": "@waku/interfaces",
"version": "0.0.16", "version": "0.0.17",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"devDependencies": { "devDependencies": {
"@chainsafe/libp2p-gossipsub": "^9.1.0", "@chainsafe/libp2p-gossipsub": "^9.1.0",
@ -27770,14 +27770,14 @@
}, },
"packages/message-encryption": { "packages/message-encryption": {
"name": "@waku/message-encryption", "name": "@waku/message-encryption",
"version": "0.0.19", "version": "0.0.20",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"dependencies": { "dependencies": {
"@noble/secp256k1": "^1.7.1", "@noble/secp256k1": "^1.7.1",
"@waku/core": "0.0.21", "@waku/core": "0.0.22",
"@waku/interfaces": "0.0.16", "@waku/interfaces": "0.0.17",
"@waku/proto": "0.0.5", "@waku/proto": "0.0.5",
"@waku/utils": "0.0.9", "@waku/utils": "0.0.10",
"debug": "^4.3.4", "debug": "^4.3.4",
"js-sha3": "^0.8.0" "js-sha3": "^0.8.0"
}, },
@ -27832,11 +27832,11 @@
}, },
"packages/message-hash": { "packages/message-hash": {
"name": "@waku/message-hash", "name": "@waku/message-hash",
"version": "0.1.5", "version": "0.1.6",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"dependencies": { "dependencies": {
"@noble/hashes": "^1.2.0", "@noble/hashes": "^1.2.0",
"@waku/utils": "0.0.9" "@waku/utils": "0.0.10"
}, },
"devDependencies": { "devDependencies": {
"@rollup/plugin-commonjs": "^24.0.1", "@rollup/plugin-commonjs": "^24.0.1",
@ -27846,7 +27846,7 @@
"@types/debug": "^4.1.7", "@types/debug": "^4.1.7",
"@types/mocha": "^10.0.1", "@types/mocha": "^10.0.1",
"@waku/build-utils": "*", "@waku/build-utils": "*",
"@waku/interfaces": "0.0.16", "@waku/interfaces": "0.0.17",
"chai": "^4.3.7", "chai": "^4.3.7",
"cspell": "^6.28.0", "cspell": "^6.28.0",
"fast-check": "^3.7.0", "fast-check": "^3.7.0",
@ -27872,16 +27872,16 @@
}, },
"packages/peer-exchange": { "packages/peer-exchange": {
"name": "@waku/peer-exchange", "name": "@waku/peer-exchange",
"version": "0.0.14", "version": "0.0.15",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"dependencies": { "dependencies": {
"@libp2p/interface-peer-discovery": "^2.0.0", "@libp2p/interface-peer-discovery": "^2.0.0",
"@libp2p/interfaces": "^3.3.2", "@libp2p/interfaces": "^3.3.2",
"@waku/core": "0.0.21", "@waku/core": "0.0.22",
"@waku/enr": "0.0.15", "@waku/enr": "0.0.16",
"@waku/interfaces": "0.0.16", "@waku/interfaces": "0.0.17",
"@waku/proto": "0.0.5", "@waku/proto": "0.0.5",
"@waku/utils": "0.0.9", "@waku/utils": "0.0.10",
"debug": "^4.3.4", "debug": "^4.3.4",
"it-all": "^3.0.2", "it-all": "^3.0.2",
"it-length-prefixed": "^9.0.1", "it-length-prefixed": "^9.0.1",
@ -27965,15 +27965,15 @@
}, },
"packages/relay": { "packages/relay": {
"name": "@waku/relay", "name": "@waku/relay",
"version": "0.0.4", "version": "0.0.5",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"dependencies": { "dependencies": {
"@chainsafe/libp2p-gossipsub": "^9.1.0", "@chainsafe/libp2p-gossipsub": "^9.1.0",
"@noble/hashes": "^1.3.0", "@noble/hashes": "^1.3.0",
"@waku/core": "0.0.21", "@waku/core": "0.0.22",
"@waku/interfaces": "0.0.16", "@waku/interfaces": "0.0.17",
"@waku/proto": "0.0.5", "@waku/proto": "0.0.5",
"@waku/utils": "0.0.9", "@waku/utils": "0.0.10",
"chai": "^4.3.7", "chai": "^4.3.7",
"debug": "^4.3.4", "debug": "^4.3.4",
"fast-check": "^3.8.1" "fast-check": "^3.8.1"
@ -27995,17 +27995,17 @@
}, },
"packages/sdk": { "packages/sdk": {
"name": "@waku/sdk", "name": "@waku/sdk",
"version": "0.0.17", "version": "0.0.18",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"dependencies": { "dependencies": {
"@chainsafe/libp2p-noise": "^12.0.1", "@chainsafe/libp2p-noise": "^12.0.1",
"@libp2p/mplex": "^8.0.4", "@libp2p/mplex": "^8.0.4",
"@libp2p/websockets": "^6.0.3", "@libp2p/websockets": "^6.0.3",
"@waku/core": "0.0.21", "@waku/core": "0.0.22",
"@waku/dns-discovery": "0.0.15", "@waku/dns-discovery": "0.0.16",
"@waku/interfaces": "0.0.16", "@waku/interfaces": "0.0.17",
"@waku/relay": "0.0.4", "@waku/relay": "0.0.5",
"@waku/utils": "0.0.9", "@waku/utils": "0.0.10",
"libp2p": "^0.45.9" "libp2p": "^0.45.9"
}, },
"devDependencies": { "devDependencies": {
@ -28326,7 +28326,7 @@
}, },
"packages/utils": { "packages/utils": {
"name": "@waku/utils", "name": "@waku/utils",
"version": "0.0.9", "version": "0.0.10",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"dependencies": { "dependencies": {
"debug": "^4.3.4", "debug": "^4.3.4",
@ -28340,7 +28340,7 @@
"@rollup/plugin-json": "^6.0.0", "@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.2", "@rollup/plugin-node-resolve": "^15.0.2",
"@waku/build-utils": "*", "@waku/build-utils": "*",
"@waku/interfaces": "0.0.16", "@waku/interfaces": "0.0.17",
"cspell": "^6.31.1", "cspell": "^6.31.1",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"prettier": "^2.8.8", "prettier": "^2.8.8",
@ -32143,9 +32143,9 @@
"@types/mocha": "^10.0.1", "@types/mocha": "^10.0.1",
"@types/uuid": "^9.0.1", "@types/uuid": "^9.0.1",
"@waku/build-utils": "*", "@waku/build-utils": "*",
"@waku/interfaces": "0.0.16", "@waku/interfaces": "0.0.17",
"@waku/proto": "0.0.5", "@waku/proto": "0.0.5",
"@waku/utils": "0.0.9", "@waku/utils": "0.0.10",
"chai": "^4.3.7", "chai": "^4.3.7",
"cspell": "^6.31.1", "cspell": "^6.31.1",
"debug": "^4.3.4", "debug": "^4.3.4",
@ -32193,9 +32193,9 @@
"@rollup/plugin-node-resolve": "^15.0.2", "@rollup/plugin-node-resolve": "^15.0.2",
"@types/chai": "^4.3.4", "@types/chai": "^4.3.4",
"@waku/build-utils": "*", "@waku/build-utils": "*",
"@waku/enr": "0.0.15", "@waku/enr": "0.0.16",
"@waku/interfaces": "0.0.16", "@waku/interfaces": "0.0.17",
"@waku/utils": "0.0.9", "@waku/utils": "0.0.10",
"chai": "^4.3.7", "chai": "^4.3.7",
"cspell": "^6.31.1", "cspell": "^6.31.1",
"debug": "^4.3.4", "debug": "^4.3.4",
@ -32240,8 +32240,8 @@
"@types/chai": "^4.3.4", "@types/chai": "^4.3.4",
"@types/mocha": "^10.0.1", "@types/mocha": "^10.0.1",
"@waku/build-utils": "*", "@waku/build-utils": "*",
"@waku/interfaces": "0.0.16", "@waku/interfaces": "0.0.17",
"@waku/utils": "0.0.9", "@waku/utils": "0.0.10",
"chai": "^4.3.7", "chai": "^4.3.7",
"cspell": "^6.31.1", "cspell": "^6.31.1",
"debug": "^4.3.4", "debug": "^4.3.4",
@ -32309,10 +32309,10 @@
"@types/chai": "^4.3.4", "@types/chai": "^4.3.4",
"@types/mocha": "^10.0.1", "@types/mocha": "^10.0.1",
"@waku/build-utils": "*", "@waku/build-utils": "*",
"@waku/core": "0.0.21", "@waku/core": "0.0.22",
"@waku/interfaces": "0.0.16", "@waku/interfaces": "0.0.17",
"@waku/proto": "0.0.5", "@waku/proto": "0.0.5",
"@waku/utils": "0.0.9", "@waku/utils": "0.0.10",
"chai": "^4.3.7", "chai": "^4.3.7",
"cspell": "^6.31.1", "cspell": "^6.31.1",
"debug": "^4.3.4", "debug": "^4.3.4",
@ -32356,8 +32356,8 @@
"@types/debug": "^4.1.7", "@types/debug": "^4.1.7",
"@types/mocha": "^10.0.1", "@types/mocha": "^10.0.1",
"@waku/build-utils": "*", "@waku/build-utils": "*",
"@waku/interfaces": "0.0.16", "@waku/interfaces": "0.0.17",
"@waku/utils": "0.0.9", "@waku/utils": "0.0.10",
"chai": "^4.3.7", "chai": "^4.3.7",
"cspell": "^6.28.0", "cspell": "^6.28.0",
"fast-check": "^3.7.0", "fast-check": "^3.7.0",
@ -32393,11 +32393,11 @@
"@rollup/plugin-json": "^6.0.0", "@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.2", "@rollup/plugin-node-resolve": "^15.0.2",
"@waku/build-utils": "*", "@waku/build-utils": "*",
"@waku/core": "0.0.21", "@waku/core": "0.0.22",
"@waku/enr": "0.0.15", "@waku/enr": "0.0.16",
"@waku/interfaces": "0.0.16", "@waku/interfaces": "0.0.17",
"@waku/proto": "0.0.5", "@waku/proto": "0.0.5",
"@waku/utils": "0.0.9", "@waku/utils": "0.0.10",
"chai": "^4.3.7", "chai": "^4.3.7",
"cspell": "^6.31.1", "cspell": "^6.31.1",
"debug": "^4.3.4", "debug": "^4.3.4",
@ -32459,10 +32459,10 @@
"@rollup/plugin-json": "^6.0.0", "@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.2", "@rollup/plugin-node-resolve": "^15.0.2",
"@waku/build-utils": "*", "@waku/build-utils": "*",
"@waku/core": "0.0.21", "@waku/core": "0.0.22",
"@waku/interfaces": "0.0.16", "@waku/interfaces": "0.0.17",
"@waku/proto": "0.0.5", "@waku/proto": "0.0.5",
"@waku/utils": "0.0.9", "@waku/utils": "0.0.10",
"chai": "^4.3.7", "chai": "^4.3.7",
"debug": "^4.3.4", "debug": "^4.3.4",
"fast-check": "^3.8.1", "fast-check": "^3.8.1",
@ -32497,11 +32497,11 @@
"@rollup/plugin-json": "^6.0.0", "@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.2", "@rollup/plugin-node-resolve": "^15.0.2",
"@waku/build-utils": "*", "@waku/build-utils": "*",
"@waku/core": "0.0.21", "@waku/core": "0.0.22",
"@waku/dns-discovery": "0.0.15", "@waku/dns-discovery": "0.0.16",
"@waku/interfaces": "0.0.16", "@waku/interfaces": "0.0.17",
"@waku/relay": "0.0.4", "@waku/relay": "0.0.5",
"@waku/utils": "0.0.9", "@waku/utils": "0.0.10",
"cspell": "^6.31.1", "cspell": "^6.31.1",
"interface-datastore": "^7.0.4", "interface-datastore": "^7.0.4",
"libp2p": "^0.45.9", "libp2p": "^0.45.9",
@ -32709,7 +32709,7 @@
"@rollup/plugin-json": "^6.0.0", "@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.2", "@rollup/plugin-node-resolve": "^15.0.2",
"@waku/build-utils": "*", "@waku/build-utils": "*",
"@waku/interfaces": "0.0.16", "@waku/interfaces": "0.0.17",
"cspell": "^6.31.1", "cspell": "^6.31.1",
"debug": "^4.3.4", "debug": "^4.3.4",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",

View File

@ -1,6 +1,5 @@
{ {
"extension": ["ts"], "extension": ["ts"],
"spec": "tests/*.spec.ts",
"require": ["ts-node/register", "isomorphic-fetch"], "require": ["ts-node/register", "isomorphic-fetch"],
"loader": "ts-node/esm", "loader": "ts-node/esm",
"node-option": [ "node-option": [

View File

@ -41,8 +41,8 @@
"check:lint": "eslint src tests", "check:lint": "eslint src tests",
"check:spelling": "cspell \"{README.md,{tests,src}/**/*.ts}\"", "check:spelling": "cspell \"{README.md,{tests,src}/**/*.ts}\"",
"check:tsc": "tsc -p tsconfig.dev.json", "check:tsc": "tsc -p tsconfig.dev.json",
"test": "run-s test:*", "test": "node ./src/run-tests.js \"tests/**/!(*.optional).spec.ts\"",
"test:node": "node ./src/run-tests.js", "test:optional": "node ./src/run-tests.js \"tests/**/@(*.optional).spec.ts\"",
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build" "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build"
}, },
"engines": { "engines": {

View File

@ -25,6 +25,7 @@ async function main() {
"ts-node/register", "ts-node/register",
"--project", "--project",
"./tsconfig.dev.json", "./tsconfig.dev.json",
...process.argv.slice(2),
], ],
{ {
stdio: "inherit", stdio: "inherit",

View File

@ -1,9 +1,4 @@
import { bootstrap } from "@libp2p/bootstrap";
import tests from "@libp2p/interface-peer-discovery-compliance-tests"; import tests from "@libp2p/interface-peer-discovery-compliance-tests";
import {
Fleet,
getPredefinedBootstrapNodes,
} from "@waku/core/lib/predefined_bootstrap_nodes";
import type { LightNode, PeerInfo } from "@waku/interfaces"; import type { LightNode, PeerInfo } from "@waku/interfaces";
import { import {
PeerExchangeCodec, PeerExchangeCodec,
@ -19,54 +14,12 @@ import { makeLogFileName } from "../src/log_file.js";
import { NimGoNode } from "../src/node/node.js"; import { NimGoNode } from "../src/node/node.js";
describe("Peer Exchange", () => { describe("Peer Exchange", () => {
describe("Auto Discovery", function () {
let waku: LightNode;
afterEach(async function () {
await waku?.stop();
});
it("connection with fleet nodes", async function () {
// skipping in CI as this test demonstrates Peer Exchange working with the test fleet
// but not with locally run nwaku nodes
if (process.env.CI) {
this.skip();
}
this.timeout(50_000);
waku = await createLightNode({
libp2p: {
peerDiscovery: [
bootstrap({ list: getPredefinedBootstrapNodes(Fleet.Test, 3) }),
wakuPeerExchangeDiscovery(),
],
},
});
await waku.start();
const foundPxPeer = await new Promise<boolean>((resolve) => {
const testNodes = getPredefinedBootstrapNodes(Fleet.Test, 3);
waku.libp2p.addEventListener("peer:discovery", (evt) => {
const peerId = evt.detail.id.toString();
const isBootstrapNode = testNodes.find((n) => n.includes(peerId));
if (!isBootstrapNode) {
resolve(true);
}
});
});
expect(foundPxPeer).to.be.true;
});
});
describe("Locally Run Nodes", () => { describe("Locally Run Nodes", () => {
let waku: LightNode; let waku: LightNode;
let nwaku1: NimGoNode; let nwaku1: NimGoNode;
let nwaku2: NimGoNode; let nwaku2: NimGoNode;
beforeEach(async function () { beforeEach(function () {
nwaku1 = new NimGoNode(makeLogFileName(this) + "1"); nwaku1 = new NimGoNode(makeLogFileName(this) + "1");
nwaku2 = new NimGoNode(makeLogFileName(this) + "2"); nwaku2 = new NimGoNode(makeLogFileName(this) + "2");
}); });

View File

@ -0,0 +1,56 @@
import { bootstrap } from "@libp2p/bootstrap";
import {
Fleet,
getPredefinedBootstrapNodes,
} from "@waku/core/lib/predefined_bootstrap_nodes";
import type { LightNode } from "@waku/interfaces";
import { wakuPeerExchangeDiscovery } from "@waku/peer-exchange";
import { createLightNode } from "@waku/sdk";
import { expect } from "chai";
describe("Peer Exchange", () => {
describe("Auto Discovery", function () {
let waku: LightNode;
afterEach(async function () {
await waku?.stop();
});
const testCases: [Fleet, number][] = [
[Fleet.Test, 2], // on test fleet there are only 3 peers
[Fleet.Prod, 3],
];
testCases.map(([name, nodes]) => {
it(`should discover peers other than used for bootstrapping on ${name} fleet`, async function () {
this.timeout(50_000);
const predefinedNodes = getPredefinedBootstrapNodes(name, nodes);
waku = await createLightNode({
libp2p: {
peerDiscovery: [
bootstrap({ list: predefinedNodes }),
wakuPeerExchangeDiscovery(),
],
},
});
await waku.start();
const foundPxPeer = await new Promise<boolean>((resolve) => {
waku.libp2p.addEventListener("peer:discovery", (evt) => {
const peerId = evt.detail.id.toString();
const isBootstrapNode = predefinedNodes.find((n) =>
n.includes(peerId)
);
if (!isBootstrapNode) {
resolve(true);
}
});
});
expect(foundPxPeer).to.be.true;
});
});
});
});