From b11d465a9dfded7dc13d1ebe7bd88a16f3e3e360 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 1 Nov 2022 21:31:53 +1100 Subject: [PATCH] chore: move tests to remove circular dep --- packages/core/package.json | 8 +++ packages/core/rollup.config.js | 2 + packages/core/typedoc.json | 2 + packages/tests/.eslintrc.cjs | 3 + packages/tests/.mocharc.json | 2 +- packages/tests/package.json | 14 ++++- .../src/test_utils => tests/src}/async_fs.ts | 0 .../src/test_utils => tests/src}/constants.ts | 0 .../src/test_utils => tests/src}/delay.ts | 0 .../src/test_utils => tests/src}/index.ts | 0 .../src/test_utils => tests/src}/log_file.ts | 0 .../src/test_utils => tests/src}/nwaku.ts | 12 ++-- packages/tests/tests/enr.node.spec.ts | 13 ++-- packages/tests/tests/filter.node.spec.ts | 12 ++-- packages/tests/tests/light_push.node.spec.ts | 14 +++-- .../tests}/log_file.node.spec.ts | 2 +- .../tests}/nwaku.node.spec.ts | 2 +- packages/tests/tests/relay.node.spec.ts | 44 ++++++++------ packages/tests/tests/store.node.spec.ts | 60 ++++++++++++------- .../tests/wait_for_remote_peer.node.spec.ts | 25 ++++++-- packages/tests/tests/waku.node.spec.ts | 24 ++++---- packages/tests/tsconfig.json | 4 +- 22 files changed, 156 insertions(+), 87 deletions(-) rename packages/{core/src/test_utils => tests/src}/async_fs.ts (100%) rename packages/{core/src/test_utils => tests/src}/constants.ts (100%) rename packages/{core/src/test_utils => tests/src}/delay.ts (100%) rename packages/{core/src/test_utils => tests/src}/index.ts (100%) rename packages/{core/src/test_utils => tests/src}/log_file.ts (100%) rename packages/{core/src/test_utils => tests/src}/nwaku.ts (98%) rename packages/{core/src/test_utils => tests/tests}/log_file.node.spec.ts (90%) rename packages/{core/src/test_utils => tests/tests}/nwaku.node.spec.ts (90%) diff --git a/packages/core/package.json b/packages/core/package.json index 765c9f2b42..488944f962 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -9,6 +9,10 @@ "types": "./dist/index.d.ts", "import": "./dist/index.js" }, + "./lib/enr": { + "types": "./dist/lib/enr/index.d.ts", + "import": "./dist/lib/enr/index.js" + }, "./lib/peer_discovery_dns": { "types": "./dist/lib/peer_discovery_dns/index.d.ts", "import": "./dist/lib/peer_discovery_dns/index.js" @@ -21,6 +25,10 @@ "types": "./dist/lib/predefined_bootstrap_nodes.d.ts", "import": "./dist/lib/predefined_bootstrap_nodes.js" }, + "./lib/utils": { + "types": "./dist/lib/utils.d.ts", + "import": "./dist/lib/utils.js" + }, "./lib/wait_for_remote_peer": { "types": "./dist/lib/wait_for_remote_peer.d.ts", "import": "./dist/lib/wait_for_remote_peer.js" diff --git a/packages/core/rollup.config.js b/packages/core/rollup.config.js index 79fd67420e..4b2cd71a2d 100644 --- a/packages/core/rollup.config.js +++ b/packages/core/rollup.config.js @@ -5,9 +5,11 @@ import json from "@rollup/plugin-json"; export default { input: { index: "dist/index.js", + "lib/enr": "dist/lib/enr/index.js", "lib/peer_discovery_dns": "dist/lib/peer_discovery_dns/index.js", "lib/peer_discovery_static_list": "dist/lib/peer_discovery_static_list.js", "lib/predefined_bootstrap_nodes": "dist/lib/predefined_bootstrap_nodes.js", + "lib/utils": "dist/lib/utils.js", "lib/wait_for_remote_peer": "dist/lib/wait_for_remote_peer.js", "lib/waku_message/version_0": "dist/lib/waku_message/version_0.js", "lib/waku_message/version_1": "dist/lib/waku_message/version_1.js", diff --git a/packages/core/typedoc.json b/packages/core/typedoc.json index 031b751650..0e56836bb7 100644 --- a/packages/core/typedoc.json +++ b/packages/core/typedoc.json @@ -1,9 +1,11 @@ { "entryPoints": [ "./src/index.ts", + "./src/lib/enr/index.ts", "./src/lib/peer_discovery_dns.ts", "./src/lib/peer_discovery_static_list.ts", "./src/lib/predefined_bootstrap_nodes.ts", + "./src/lib/utils.ts", "./src/lib/wait_for_remote_peer.ts", "./src/lib/waku_message/version_0.ts", "./src/lib/waku_message/version_1.ts", diff --git a/packages/tests/.eslintrc.cjs b/packages/tests/.eslintrc.cjs index 37c79ff066..cb52e850cc 100644 --- a/packages/tests/.eslintrc.cjs +++ b/packages/tests/.eslintrc.cjs @@ -3,4 +3,7 @@ module.exports = { tsconfigRootDir: __dirname, project: "./tsconfig.json", }, + rules: { + "@typescript-eslint/no-non-null-assertion": "off", + }, }; diff --git a/packages/tests/.mocharc.json b/packages/tests/.mocharc.json index db9dd73531..0658ab762d 100644 --- a/packages/tests/.mocharc.json +++ b/packages/tests/.mocharc.json @@ -1,6 +1,6 @@ { "extension": ["ts"], - "spec": "src/**/*.spec.ts", + "spec": "tests/**/*.spec.ts", "require": ["ts-node/register", "isomorphic-fetch", "jsdom-global/register"], "loader": "ts-node/esm", "node-option": [ diff --git a/packages/tests/package.json b/packages/tests/package.json index f7bbc3b112..a340235a64 100644 --- a/packages/tests/package.json +++ b/packages/tests/package.json @@ -43,12 +43,20 @@ "scripts": { "fix": "run-s fix:*", "fix:prettier": "prettier . --write", - "fix:lint": "eslint tests --ext .ts --ext .cjs --fix", + "fix:lint": "eslint src tests --ext .ts --ext .cjs --fix", + "pretest": "run-s pretest:*", + "pretest:1-init-git-submodules": "[ -f '../../nwaku/build/wakunode2' ] || git submodule update --init --recursive", + "pretest:2-build-nwaku": "[ -f '../../nwaku/build/wakunode2' ] || run-s nwaku:build", + "nwaku:build": "(PROC=$(nproc --all 2>/dev/null || echo 2); cd ../../nwaku; make -j$PROC update; NIMFLAGS=\"-d:chronicles_colors=off -d:chronicles_sinks=textlines -d:chronicles_log_level=TRACE\" make -j$PROC wakunode2)", + "nwaku:force-build": "(cd ../../nwaku && rm -rf ./build/ ./vendor) && run-s nwaku:build", "check": "run-s check:*", - "check:lint": "eslint tests --ext .ts", + "check:lint": "eslint src tests --ext .ts", "check:prettier": "prettier . --list-different", - "check:spelling": "cspell \"{README.md,src/**/*.ts}\"", + "check:spelling": "cspell \"{README.md,{tests,src}/**/*.ts}\"", "check:tsc": "tsc -p tsconfig.json", + "test": "run-s test:*", + "test:node": "TS_NODE_PROJECT=./tsconfig.json mocha", + "test:browser": "karma start karma.conf.cjs", "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build" }, "engines": { diff --git a/packages/core/src/test_utils/async_fs.ts b/packages/tests/src/async_fs.ts similarity index 100% rename from packages/core/src/test_utils/async_fs.ts rename to packages/tests/src/async_fs.ts diff --git a/packages/core/src/test_utils/constants.ts b/packages/tests/src/constants.ts similarity index 100% rename from packages/core/src/test_utils/constants.ts rename to packages/tests/src/constants.ts diff --git a/packages/core/src/test_utils/delay.ts b/packages/tests/src/delay.ts similarity index 100% rename from packages/core/src/test_utils/delay.ts rename to packages/tests/src/delay.ts diff --git a/packages/core/src/test_utils/index.ts b/packages/tests/src/index.ts similarity index 100% rename from packages/core/src/test_utils/index.ts rename to packages/tests/src/index.ts diff --git a/packages/core/src/test_utils/log_file.ts b/packages/tests/src/log_file.ts similarity index 100% rename from packages/core/src/test_utils/log_file.ts rename to packages/tests/src/log_file.ts diff --git a/packages/core/src/test_utils/nwaku.ts b/packages/tests/src/nwaku.ts similarity index 98% rename from packages/core/src/test_utils/nwaku.ts rename to packages/tests/src/nwaku.ts index 3027963bb5..15ef495690 100644 --- a/packages/core/src/test_utils/nwaku.ts +++ b/packages/tests/src/nwaku.ts @@ -1,24 +1,20 @@ -/** - * @hidden - * @module - */ - import { ChildProcess, spawn } from "child_process"; import type { PeerId } from "@libp2p/interface-peer-id"; import { peerIdFromString } from "@libp2p/peer-id"; import { Multiaddr, multiaddr } from "@multiformats/multiaddr"; +import { DefaultPubSubTopic } from "@waku/core"; +import { utils } from "@waku/core"; import appRoot from "app-root-path"; import debug from "debug"; import portfinder from "portfinder"; -import { DefaultPubSubTopic } from "../lib/constants"; -import { bytesToHex, hexToBytes } from "../lib/utils"; - import { existsAsync, mkdirAsync, openAsync } from "./async_fs"; import { delay } from "./delay"; import waitForLine from "./log_file"; +const { bytesToHex, hexToBytes } = utils; + const log = debug("waku:nwaku"); const WAKU_SERVICE_NODE_DIR = diff --git a/packages/tests/tests/enr.node.spec.ts b/packages/tests/tests/enr.node.spec.ts index 24b1d3704c..3bfabbe2e3 100644 --- a/packages/tests/tests/enr.node.spec.ts +++ b/packages/tests/tests/enr.node.spec.ts @@ -1,12 +1,11 @@ +import { ENR } from "@waku/core/lib/enr"; +import { waitForRemotePeer } from "@waku/core/lib/wait_for_remote_peer"; import { createPrivacyNode } from "@waku/create"; import type { WakuPrivacy } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; -import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../../test_utils"; -import { waitForRemotePeer } from "../wait_for_remote_peer"; - -import { ENR } from "./enr"; +import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../src"; describe("ENR Interop: nwaku", function () { let waku: WakuPrivacy; @@ -32,6 +31,8 @@ describe("ENR Interop: nwaku", function () { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(multiAddrWithId); await waitForRemotePeer(waku, [Protocols.Relay]); @@ -64,6 +65,8 @@ describe("ENR Interop: nwaku", function () { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(multiAddrWithId); await waitForRemotePeer(waku, [Protocols.Relay]); @@ -96,6 +99,8 @@ describe("ENR Interop: nwaku", function () { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(multiAddrWithId); await waitForRemotePeer(waku, [Protocols.Relay]); diff --git a/packages/tests/tests/filter.node.spec.ts b/packages/tests/tests/filter.node.spec.ts index 705a813691..561e58d8b8 100644 --- a/packages/tests/tests/filter.node.spec.ts +++ b/packages/tests/tests/filter.node.spec.ts @@ -1,14 +1,14 @@ +import { bytesToUtf8, utf8ToBytes } from "@waku/core/lib/utils"; +import { waitForRemotePeer } from "@waku/core/lib/wait_for_remote_peer"; +import { DecoderV0, EncoderV0 } from "@waku/core/lib/waku_message/version_0"; import { createFullNode } from "@waku/create"; import type { Message, WakuFull } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; import debug from "debug"; -import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../../test_utils"; -import { delay } from "../../test_utils/delay"; -import { bytesToUtf8, utf8ToBytes } from "../utils"; -import { waitForRemotePeer } from "../wait_for_remote_peer"; -import { DecoderV0, EncoderV0 } from "../waku_message/version_0"; +import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../src"; +import { delay } from "../src/delay"; const log = debug("waku:test"); @@ -34,6 +34,8 @@ describe("Waku Filter", () => { libp2p: { addresses: { listen: ["/ip4/0.0.0.0/tcp/0/ws"] } }, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Filter, Protocols.LightPush]); }); diff --git a/packages/tests/tests/light_push.node.spec.ts b/packages/tests/tests/light_push.node.spec.ts index f05a0234cb..f937e54a22 100644 --- a/packages/tests/tests/light_push.node.spec.ts +++ b/packages/tests/tests/light_push.node.spec.ts @@ -1,3 +1,6 @@ +import { bytesToUtf8, utf8ToBytes } from "@waku/core/lib/utils"; +import { waitForRemotePeer } from "@waku/core/lib/wait_for_remote_peer"; +import { EncoderV0 } from "@waku/core/lib/waku_message/version_0"; import { createFullNode } from "@waku/create"; import type { WakuFull } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; @@ -9,11 +12,8 @@ import { MessageRpcResponse, NOISE_KEY_1, Nwaku, -} from "../../test_utils"; -import { delay } from "../../test_utils/delay"; -import { bytesToUtf8, utf8ToBytes } from "../utils"; -import { waitForRemotePeer } from "../wait_for_remote_peer"; -import { EncoderV0 } from "../waku_message/version_0"; +} from "../src"; +import { delay } from "../src/delay"; const log = debug("waku:test:lightpush"); @@ -39,6 +39,8 @@ describe("Waku Light Push [node only]", () => { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.LightPush]); @@ -73,6 +75,8 @@ describe("Waku Light Push [node only]", () => { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.LightPush]); diff --git a/packages/core/src/test_utils/log_file.node.spec.ts b/packages/tests/tests/log_file.node.spec.ts similarity index 90% rename from packages/core/src/test_utils/log_file.node.spec.ts rename to packages/tests/tests/log_file.node.spec.ts index c72d3098d0..0d40474b6f 100644 --- a/packages/core/src/test_utils/log_file.node.spec.ts +++ b/packages/tests/tests/log_file.node.spec.ts @@ -1,6 +1,6 @@ import { expect } from "chai"; -import { makeLogFileName } from "./log_file"; +import { makeLogFileName } from "../src"; describe("This", function () { describe("Is", function () { diff --git a/packages/core/src/test_utils/nwaku.node.spec.ts b/packages/tests/tests/nwaku.node.spec.ts similarity index 90% rename from packages/core/src/test_utils/nwaku.node.spec.ts rename to packages/tests/tests/nwaku.node.spec.ts index d2f7e05222..5299aab3f6 100644 --- a/packages/core/src/test_utils/nwaku.node.spec.ts +++ b/packages/tests/tests/nwaku.node.spec.ts @@ -1,6 +1,6 @@ import { expect } from "chai"; -import { argsToArray, defaultArgs } from "./nwaku"; +import { argsToArray, defaultArgs } from "../src"; describe("nwaku", () => { it("Correctly serialized arguments", function () { diff --git a/packages/tests/tests/relay.node.spec.ts b/packages/tests/tests/relay.node.spec.ts index 7b0af2cdfc..bab30edce3 100644 --- a/packages/tests/tests/relay.node.spec.ts +++ b/packages/tests/tests/relay.node.spec.ts @@ -1,4 +1,23 @@ import { PeerId } from "@libp2p/interface-peer-id"; +import { DefaultPubSubTopic } from "@waku/core"; +import { + generatePrivateKey, + generateSymmetricKey, + getPublicKey, +} from "@waku/core"; +import { bytesToUtf8, utf8ToBytes } from "@waku/core/lib/utils"; +import { waitForRemotePeer } from "@waku/core/lib/wait_for_remote_peer"; +import { + DecoderV0, + EncoderV0, + MessageV0, +} from "@waku/core/lib/waku_message/version_0"; +import { + AsymDecoder, + AsymEncoder, + SymDecoder, + SymEncoder, +} from "@waku/core/lib/waku_message/version_1"; import { createPrivacyNode } from "@waku/create"; import type { Message, WakuPrivacy } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; @@ -12,23 +31,8 @@ import { NOISE_KEY_2, NOISE_KEY_3, Nwaku, -} from "../../test_utils"; -import { delay } from "../../test_utils/delay"; -import { DefaultPubSubTopic } from "../constants"; -import { - generatePrivateKey, - generateSymmetricKey, - getPublicKey, -} from "../crypto"; -import { bytesToUtf8, utf8ToBytes } from "../utils"; -import { waitForRemotePeer } from "../wait_for_remote_peer"; -import { DecoderV0, EncoderV0, MessageV0 } from "../waku_message/version_0.js"; -import { - AsymDecoder, - AsymEncoder, - SymDecoder, - SymEncoder, -} from "../waku_message/version_1.js"; +} from "../src"; +import { delay } from "../src/delay"; const log = debug("waku:test"); @@ -342,6 +346,8 @@ describe("Waku Relay [node only]", () => { nwaku = new Nwaku(this.test?.ctx?.currentTest?.title + ""); await nwaku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Relay]); }); @@ -439,7 +445,11 @@ describe("Waku Relay [node only]", () => { const nwakuMultiaddr = await nwaku.getMultiaddrWithId(); await Promise.all([ + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos waku1.dial(nwakuMultiaddr), + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos waku2.dial(nwakuMultiaddr), ]); diff --git a/packages/tests/tests/store.node.spec.ts b/packages/tests/tests/store.node.spec.ts index 5cd8fc39e9..fb779059b2 100644 --- a/packages/tests/tests/store.node.spec.ts +++ b/packages/tests/tests/store.node.spec.ts @@ -1,31 +1,25 @@ +import { + generatePrivateKey, + generateSymmetricKey, + getPublicKey, +} from "@waku/core"; +import { PageDirection } from "@waku/core"; +import { bytesToUtf8, utf8ToBytes } from "@waku/core/lib/utils"; +import { waitForRemotePeer } from "@waku/core/lib/wait_for_remote_peer"; +import { DecoderV0, EncoderV0 } from "@waku/core/lib/waku_message/version_0"; +import { + AsymDecoder, + AsymEncoder, + SymDecoder, + SymEncoder, +} from "@waku/core/lib/waku_message/version_1"; import { createFullNode } from "@waku/create"; import type { Message, WakuFull } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; import debug from "debug"; -import { - makeLogFileName, - NOISE_KEY_1, - NOISE_KEY_2, - Nwaku, -} from "../../test_utils"; -import { - generatePrivateKey, - generateSymmetricKey, - getPublicKey, -} from "../crypto"; -import { bytesToUtf8, utf8ToBytes } from "../utils"; -import { waitForRemotePeer } from "../wait_for_remote_peer"; -import { DecoderV0, EncoderV0 } from "../waku_message/version_0.js"; -import { - AsymDecoder, - AsymEncoder, - SymDecoder, - SymEncoder, -} from "../waku_message/version_1.js"; - -import { PageDirection } from "./history_rpc"; +import { makeLogFileName, NOISE_KEY_1, NOISE_KEY_2, Nwaku } from "../src"; const log = debug("waku:test:store"); @@ -67,6 +61,8 @@ describe("Waku Store", () => { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Store]); @@ -98,6 +94,8 @@ describe("Waku Store", () => { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Store]); @@ -138,6 +136,8 @@ describe("Waku Store", () => { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Store]); @@ -179,6 +179,8 @@ describe("Waku Store", () => { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Store]); @@ -218,6 +220,8 @@ describe("Waku Store", () => { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Store]); @@ -261,6 +265,8 @@ describe("Waku Store", () => { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Store]); @@ -343,7 +349,11 @@ describe("Waku Store", () => { log("Waku nodes created"); await Promise.all([ + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos waku1.dial(nimWakuMultiaddr), + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos waku2.dial(nimWakuMultiaddr), ]); @@ -425,6 +435,8 @@ describe("Waku Store", () => { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Store]); @@ -486,6 +498,8 @@ describe("Waku Store", () => { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Store]); @@ -545,6 +559,8 @@ describe("Waku Store, custom pubsub topic", () => { pubSubTopic: customPubSubTopic, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Store]); diff --git a/packages/tests/tests/wait_for_remote_peer.node.spec.ts b/packages/tests/tests/wait_for_remote_peer.node.spec.ts index 25e219b093..9ba26feeb3 100644 --- a/packages/tests/tests/wait_for_remote_peer.node.spec.ts +++ b/packages/tests/tests/wait_for_remote_peer.node.spec.ts @@ -1,12 +1,11 @@ +import { waitForRemotePeer } from "@waku/core/lib/wait_for_remote_peer"; import { createLightNode, createPrivacyNode } from "@waku/create"; import type { WakuLight, WakuPrivacy } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; -import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../test_utils"; -import { delay } from "../test_utils/delay"; - -import { waitForRemotePeer } from "./wait_for_remote_peer"; +import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../src"; +import { delay } from "../src/delay"; describe("Wait for remote peer", function () { let waku1: WakuPrivacy; @@ -37,6 +36,8 @@ describe("Wait for remote peer", function () { staticNoiseKey: NOISE_KEY_1, }); await waku1.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku1.dial(multiAddrWithId); await delay(1000); await waitForRemotePeer(waku1, [Protocols.Relay]); @@ -65,6 +66,8 @@ describe("Wait for remote peer", function () { const waitPromise = waitForRemotePeer(waku1, [Protocols.Relay]); await delay(1000); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku1.dial(multiAddrWithId); await waitPromise; @@ -110,6 +113,8 @@ describe("Wait for remote peer", function () { staticNoiseKey: NOISE_KEY_1, }); await waku2.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku2.dial(multiAddrWithId); await delay(1000); await waitForRemotePeer(waku2, [Protocols.Store]); @@ -139,6 +144,8 @@ describe("Wait for remote peer", function () { await waku2.start(); const waitPromise = waitForRemotePeer(waku2, [Protocols.Store], 2000); await delay(1000); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku2.dial(multiAddrWithId); await waitPromise; @@ -165,6 +172,8 @@ describe("Wait for remote peer", function () { staticNoiseKey: NOISE_KEY_1, }); await waku2.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku2.dial(multiAddrWithId); await waitForRemotePeer(waku2, [Protocols.LightPush]); @@ -193,6 +202,8 @@ describe("Wait for remote peer", function () { staticNoiseKey: NOISE_KEY_1, }); await waku2.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku2.dial(multiAddrWithId); await waitForRemotePeer(waku2, [Protocols.Filter]); @@ -222,6 +233,8 @@ describe("Wait for remote peer", function () { staticNoiseKey: NOISE_KEY_1, }); await waku2.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku2.dial(multiAddrWithId); await waitForRemotePeer(waku2); @@ -258,10 +271,12 @@ describe("Wait for remote peer", function () { staticNoiseKey: NOISE_KEY_1, }); await waku1.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku1.dial(multiAddrWithId); await waitForRemotePeer(waku1); - const peers = await waku1.relay.getMeshPeers(); + const peers = waku1.relay.getMeshPeers(); const nimPeerId = multiAddrWithId.getPeerId(); diff --git a/packages/tests/tests/waku.node.spec.ts b/packages/tests/tests/waku.node.spec.ts index 22187366f5..8999460ffb 100644 --- a/packages/tests/tests/waku.node.spec.ts +++ b/packages/tests/tests/waku.node.spec.ts @@ -1,21 +1,15 @@ import type { PeerId } from "@libp2p/interface-peer-id"; +import { generateSymmetricKey } from "@waku/core"; +import { PeerDiscoveryStaticPeers } from "@waku/core/lib/peer_discovery_static_list"; +import { bytesToUtf8, utf8ToBytes } from "@waku/core/lib/utils"; +import { waitForRemotePeer } from "@waku/core/lib/wait_for_remote_peer"; +import { SymDecoder, SymEncoder } from "@waku/core/lib/waku_message/version_1"; import { createLightNode, createPrivacyNode } from "@waku/create"; import type { Message, Waku, WakuLight, WakuPrivacy } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; -import { - makeLogFileName, - NOISE_KEY_1, - NOISE_KEY_2, - Nwaku, -} from "../test_utils/"; - -import { generateSymmetricKey } from "./crypto"; -import { PeerDiscoveryStaticPeers } from "./peer_discovery_static_list"; -import { bytesToUtf8, utf8ToBytes } from "./utils"; -import { waitForRemotePeer } from "./wait_for_remote_peer"; -import { SymDecoder, SymEncoder } from "./waku_message/version_1.js"; +import { makeLogFileName, NOISE_KEY_1, NOISE_KEY_2, Nwaku } from "../src/"; const TestContentTopic = "/test/1/waku/utf8"; @@ -44,6 +38,8 @@ describe("Waku Dial [node only]", function () { staticNoiseKey: NOISE_KEY_1, }); await waku.start(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos await waku.dial(multiAddrWithId); await waitForRemotePeer(waku); @@ -70,6 +66,8 @@ describe("Waku Dial [node only]", function () { waku = await createLightNode({ staticNoiseKey: NOISE_KEY_1, libp2p: { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos peerDiscovery: [new PeerDiscoveryStaticPeers([multiAddrWithId])], }, }); @@ -97,6 +95,8 @@ describe("Waku Dial [node only]", function () { staticNoiseKey: NOISE_KEY_1, libp2p: { peerDiscovery: [ + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore TODO: uniformize usage of multiaddr lib across repos new PeerDiscoveryStaticPeers([await nwaku.getMultiaddrWithId()]), ], }, diff --git a/packages/tests/tsconfig.json b/packages/tests/tsconfig.json index ae5766a55f..165ba89ee0 100644 --- a/packages/tests/tsconfig.json +++ b/packages/tests/tsconfig.json @@ -2,8 +2,6 @@ "compilerOptions": { "incremental": true, "target": "es2020", - "outDir": "dist/", - "rootDir": "tests", "noEmit": true, "moduleResolution": "node", "module": "esnext", @@ -46,7 +44,7 @@ "types": ["node", "mocha"], "typeRoots": ["node_modules/@types", "src/types"] }, - "include": ["tests"], + "include": ["tests", "src"], "compileOnSave": false, "ts-node": { "files": true