mirror of https://github.com/waku-org/js-waku.git
chore: move tests to remove circular dep
This commit is contained in:
parent
9d54462893
commit
b11d465a9d
|
@ -9,6 +9,10 @@
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"import": "./dist/index.js"
|
"import": "./dist/index.js"
|
||||||
},
|
},
|
||||||
|
"./lib/enr": {
|
||||||
|
"types": "./dist/lib/enr/index.d.ts",
|
||||||
|
"import": "./dist/lib/enr/index.js"
|
||||||
|
},
|
||||||
"./lib/peer_discovery_dns": {
|
"./lib/peer_discovery_dns": {
|
||||||
"types": "./dist/lib/peer_discovery_dns/index.d.ts",
|
"types": "./dist/lib/peer_discovery_dns/index.d.ts",
|
||||||
"import": "./dist/lib/peer_discovery_dns/index.js"
|
"import": "./dist/lib/peer_discovery_dns/index.js"
|
||||||
|
@ -21,6 +25,10 @@
|
||||||
"types": "./dist/lib/predefined_bootstrap_nodes.d.ts",
|
"types": "./dist/lib/predefined_bootstrap_nodes.d.ts",
|
||||||
"import": "./dist/lib/predefined_bootstrap_nodes.js"
|
"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": {
|
"./lib/wait_for_remote_peer": {
|
||||||
"types": "./dist/lib/wait_for_remote_peer.d.ts",
|
"types": "./dist/lib/wait_for_remote_peer.d.ts",
|
||||||
"import": "./dist/lib/wait_for_remote_peer.js"
|
"import": "./dist/lib/wait_for_remote_peer.js"
|
||||||
|
|
|
@ -5,9 +5,11 @@ import json from "@rollup/plugin-json";
|
||||||
export default {
|
export default {
|
||||||
input: {
|
input: {
|
||||||
index: "dist/index.js",
|
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_dns": "dist/lib/peer_discovery_dns/index.js",
|
||||||
"lib/peer_discovery_static_list": "dist/lib/peer_discovery_static_list.js",
|
"lib/peer_discovery_static_list": "dist/lib/peer_discovery_static_list.js",
|
||||||
"lib/predefined_bootstrap_nodes": "dist/lib/predefined_bootstrap_nodes.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/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_0": "dist/lib/waku_message/version_0.js",
|
||||||
"lib/waku_message/version_1": "dist/lib/waku_message/version_1.js",
|
"lib/waku_message/version_1": "dist/lib/waku_message/version_1.js",
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
{
|
{
|
||||||
"entryPoints": [
|
"entryPoints": [
|
||||||
"./src/index.ts",
|
"./src/index.ts",
|
||||||
|
"./src/lib/enr/index.ts",
|
||||||
"./src/lib/peer_discovery_dns.ts",
|
"./src/lib/peer_discovery_dns.ts",
|
||||||
"./src/lib/peer_discovery_static_list.ts",
|
"./src/lib/peer_discovery_static_list.ts",
|
||||||
"./src/lib/predefined_bootstrap_nodes.ts",
|
"./src/lib/predefined_bootstrap_nodes.ts",
|
||||||
|
"./src/lib/utils.ts",
|
||||||
"./src/lib/wait_for_remote_peer.ts",
|
"./src/lib/wait_for_remote_peer.ts",
|
||||||
"./src/lib/waku_message/version_0.ts",
|
"./src/lib/waku_message/version_0.ts",
|
||||||
"./src/lib/waku_message/version_1.ts",
|
"./src/lib/waku_message/version_1.ts",
|
||||||
|
|
|
@ -3,4 +3,7 @@ module.exports = {
|
||||||
tsconfigRootDir: __dirname,
|
tsconfigRootDir: __dirname,
|
||||||
project: "./tsconfig.json",
|
project: "./tsconfig.json",
|
||||||
},
|
},
|
||||||
|
rules: {
|
||||||
|
"@typescript-eslint/no-non-null-assertion": "off",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"extension": ["ts"],
|
"extension": ["ts"],
|
||||||
"spec": "src/**/*.spec.ts",
|
"spec": "tests/**/*.spec.ts",
|
||||||
"require": ["ts-node/register", "isomorphic-fetch", "jsdom-global/register"],
|
"require": ["ts-node/register", "isomorphic-fetch", "jsdom-global/register"],
|
||||||
"loader": "ts-node/esm",
|
"loader": "ts-node/esm",
|
||||||
"node-option": [
|
"node-option": [
|
||||||
|
|
|
@ -43,12 +43,20 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"fix": "run-s fix:*",
|
"fix": "run-s fix:*",
|
||||||
"fix:prettier": "prettier . --write",
|
"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": "run-s check:*",
|
||||||
"check:lint": "eslint tests --ext .ts",
|
"check:lint": "eslint src tests --ext .ts",
|
||||||
"check:prettier": "prettier . --list-different",
|
"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",
|
"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"
|
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|
|
@ -1,24 +1,20 @@
|
||||||
/**
|
|
||||||
* @hidden
|
|
||||||
* @module
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { ChildProcess, spawn } from "child_process";
|
import { ChildProcess, spawn } from "child_process";
|
||||||
|
|
||||||
import type { PeerId } from "@libp2p/interface-peer-id";
|
import type { PeerId } from "@libp2p/interface-peer-id";
|
||||||
import { peerIdFromString } from "@libp2p/peer-id";
|
import { peerIdFromString } from "@libp2p/peer-id";
|
||||||
import { Multiaddr, multiaddr } from "@multiformats/multiaddr";
|
import { Multiaddr, multiaddr } from "@multiformats/multiaddr";
|
||||||
|
import { DefaultPubSubTopic } from "@waku/core";
|
||||||
|
import { utils } from "@waku/core";
|
||||||
import appRoot from "app-root-path";
|
import appRoot from "app-root-path";
|
||||||
import debug from "debug";
|
import debug from "debug";
|
||||||
import portfinder from "portfinder";
|
import portfinder from "portfinder";
|
||||||
|
|
||||||
import { DefaultPubSubTopic } from "../lib/constants";
|
|
||||||
import { bytesToHex, hexToBytes } from "../lib/utils";
|
|
||||||
|
|
||||||
import { existsAsync, mkdirAsync, openAsync } from "./async_fs";
|
import { existsAsync, mkdirAsync, openAsync } from "./async_fs";
|
||||||
import { delay } from "./delay";
|
import { delay } from "./delay";
|
||||||
import waitForLine from "./log_file";
|
import waitForLine from "./log_file";
|
||||||
|
|
||||||
|
const { bytesToHex, hexToBytes } = utils;
|
||||||
|
|
||||||
const log = debug("waku:nwaku");
|
const log = debug("waku:nwaku");
|
||||||
|
|
||||||
const WAKU_SERVICE_NODE_DIR =
|
const WAKU_SERVICE_NODE_DIR =
|
|
@ -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 { createPrivacyNode } from "@waku/create";
|
||||||
import type { WakuPrivacy } from "@waku/interfaces";
|
import type { WakuPrivacy } from "@waku/interfaces";
|
||||||
import { Protocols } from "@waku/interfaces";
|
import { Protocols } from "@waku/interfaces";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
|
|
||||||
import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../../test_utils";
|
import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../src";
|
||||||
import { waitForRemotePeer } from "../wait_for_remote_peer";
|
|
||||||
|
|
||||||
import { ENR } from "./enr";
|
|
||||||
|
|
||||||
describe("ENR Interop: nwaku", function () {
|
describe("ENR Interop: nwaku", function () {
|
||||||
let waku: WakuPrivacy;
|
let waku: WakuPrivacy;
|
||||||
|
@ -32,6 +31,8 @@ describe("ENR Interop: nwaku", function () {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
});
|
});
|
||||||
await waku.start();
|
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 waku.dial(multiAddrWithId);
|
||||||
await waitForRemotePeer(waku, [Protocols.Relay]);
|
await waitForRemotePeer(waku, [Protocols.Relay]);
|
||||||
|
|
||||||
|
@ -64,6 +65,8 @@ describe("ENR Interop: nwaku", function () {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
});
|
});
|
||||||
await waku.start();
|
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 waku.dial(multiAddrWithId);
|
||||||
await waitForRemotePeer(waku, [Protocols.Relay]);
|
await waitForRemotePeer(waku, [Protocols.Relay]);
|
||||||
|
|
||||||
|
@ -96,6 +99,8 @@ describe("ENR Interop: nwaku", function () {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
});
|
});
|
||||||
await waku.start();
|
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 waku.dial(multiAddrWithId);
|
||||||
await waitForRemotePeer(waku, [Protocols.Relay]);
|
await waitForRemotePeer(waku, [Protocols.Relay]);
|
||||||
|
|
||||||
|
|
|
@ -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 { createFullNode } from "@waku/create";
|
||||||
import type { Message, WakuFull } from "@waku/interfaces";
|
import type { Message, WakuFull } from "@waku/interfaces";
|
||||||
import { Protocols } from "@waku/interfaces";
|
import { Protocols } from "@waku/interfaces";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import debug from "debug";
|
import debug from "debug";
|
||||||
|
|
||||||
import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../../test_utils";
|
import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../src";
|
||||||
import { delay } from "../../test_utils/delay";
|
import { delay } from "../src/delay";
|
||||||
import { bytesToUtf8, utf8ToBytes } from "../utils";
|
|
||||||
import { waitForRemotePeer } from "../wait_for_remote_peer";
|
|
||||||
import { DecoderV0, EncoderV0 } from "../waku_message/version_0";
|
|
||||||
|
|
||||||
const log = debug("waku:test");
|
const log = debug("waku:test");
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@ describe("Waku Filter", () => {
|
||||||
libp2p: { addresses: { listen: ["/ip4/0.0.0.0/tcp/0/ws"] } },
|
libp2p: { addresses: { listen: ["/ip4/0.0.0.0/tcp/0/ws"] } },
|
||||||
});
|
});
|
||||||
await waku.start();
|
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 waku.dial(await nwaku.getMultiaddrWithId());
|
||||||
await waitForRemotePeer(waku, [Protocols.Filter, Protocols.LightPush]);
|
await waitForRemotePeer(waku, [Protocols.Filter, Protocols.LightPush]);
|
||||||
});
|
});
|
||||||
|
|
|
@ -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 { createFullNode } from "@waku/create";
|
||||||
import type { WakuFull } from "@waku/interfaces";
|
import type { WakuFull } from "@waku/interfaces";
|
||||||
import { Protocols } from "@waku/interfaces";
|
import { Protocols } from "@waku/interfaces";
|
||||||
|
@ -9,11 +12,8 @@ import {
|
||||||
MessageRpcResponse,
|
MessageRpcResponse,
|
||||||
NOISE_KEY_1,
|
NOISE_KEY_1,
|
||||||
Nwaku,
|
Nwaku,
|
||||||
} from "../../test_utils";
|
} from "../src";
|
||||||
import { delay } from "../../test_utils/delay";
|
import { delay } from "../src/delay";
|
||||||
import { bytesToUtf8, utf8ToBytes } from "../utils";
|
|
||||||
import { waitForRemotePeer } from "../wait_for_remote_peer";
|
|
||||||
import { EncoderV0 } from "../waku_message/version_0";
|
|
||||||
|
|
||||||
const log = debug("waku:test:lightpush");
|
const log = debug("waku:test:lightpush");
|
||||||
|
|
||||||
|
@ -39,6 +39,8 @@ describe("Waku Light Push [node only]", () => {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
});
|
});
|
||||||
await waku.start();
|
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 waku.dial(await nwaku.getMultiaddrWithId());
|
||||||
await waitForRemotePeer(waku, [Protocols.LightPush]);
|
await waitForRemotePeer(waku, [Protocols.LightPush]);
|
||||||
|
|
||||||
|
@ -73,6 +75,8 @@ describe("Waku Light Push [node only]", () => {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
});
|
});
|
||||||
await waku.start();
|
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 waku.dial(await nwaku.getMultiaddrWithId());
|
||||||
await waitForRemotePeer(waku, [Protocols.LightPush]);
|
await waitForRemotePeer(waku, [Protocols.LightPush]);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
|
|
||||||
import { makeLogFileName } from "./log_file";
|
import { makeLogFileName } from "../src";
|
||||||
|
|
||||||
describe("This", function () {
|
describe("This", function () {
|
||||||
describe("Is", function () {
|
describe("Is", function () {
|
|
@ -1,6 +1,6 @@
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
|
|
||||||
import { argsToArray, defaultArgs } from "./nwaku";
|
import { argsToArray, defaultArgs } from "../src";
|
||||||
|
|
||||||
describe("nwaku", () => {
|
describe("nwaku", () => {
|
||||||
it("Correctly serialized arguments", function () {
|
it("Correctly serialized arguments", function () {
|
|
@ -1,4 +1,23 @@
|
||||||
import { PeerId } from "@libp2p/interface-peer-id";
|
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 { createPrivacyNode } from "@waku/create";
|
||||||
import type { Message, WakuPrivacy } from "@waku/interfaces";
|
import type { Message, WakuPrivacy } from "@waku/interfaces";
|
||||||
import { Protocols } from "@waku/interfaces";
|
import { Protocols } from "@waku/interfaces";
|
||||||
|
@ -12,23 +31,8 @@ import {
|
||||||
NOISE_KEY_2,
|
NOISE_KEY_2,
|
||||||
NOISE_KEY_3,
|
NOISE_KEY_3,
|
||||||
Nwaku,
|
Nwaku,
|
||||||
} from "../../test_utils";
|
} from "../src";
|
||||||
import { delay } from "../../test_utils/delay";
|
import { delay } from "../src/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";
|
|
||||||
|
|
||||||
const log = debug("waku:test");
|
const log = debug("waku:test");
|
||||||
|
|
||||||
|
@ -342,6 +346,8 @@ describe("Waku Relay [node only]", () => {
|
||||||
nwaku = new Nwaku(this.test?.ctx?.currentTest?.title + "");
|
nwaku = new Nwaku(this.test?.ctx?.currentTest?.title + "");
|
||||||
await nwaku.start();
|
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 waku.dial(await nwaku.getMultiaddrWithId());
|
||||||
await waitForRemotePeer(waku, [Protocols.Relay]);
|
await waitForRemotePeer(waku, [Protocols.Relay]);
|
||||||
});
|
});
|
||||||
|
@ -439,7 +445,11 @@ describe("Waku Relay [node only]", () => {
|
||||||
|
|
||||||
const nwakuMultiaddr = await nwaku.getMultiaddrWithId();
|
const nwakuMultiaddr = await nwaku.getMultiaddrWithId();
|
||||||
await Promise.all([
|
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),
|
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),
|
waku2.dial(nwakuMultiaddr),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
@ -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 { createFullNode } from "@waku/create";
|
||||||
import type { Message, WakuFull } from "@waku/interfaces";
|
import type { Message, WakuFull } from "@waku/interfaces";
|
||||||
import { Protocols } from "@waku/interfaces";
|
import { Protocols } from "@waku/interfaces";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import debug from "debug";
|
import debug from "debug";
|
||||||
|
|
||||||
import {
|
import { makeLogFileName, NOISE_KEY_1, NOISE_KEY_2, Nwaku } from "../src";
|
||||||
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";
|
|
||||||
|
|
||||||
const log = debug("waku:test:store");
|
const log = debug("waku:test:store");
|
||||||
|
|
||||||
|
@ -67,6 +61,8 @@ describe("Waku Store", () => {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
});
|
});
|
||||||
await waku.start();
|
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 waku.dial(await nwaku.getMultiaddrWithId());
|
||||||
await waitForRemotePeer(waku, [Protocols.Store]);
|
await waitForRemotePeer(waku, [Protocols.Store]);
|
||||||
|
|
||||||
|
@ -98,6 +94,8 @@ describe("Waku Store", () => {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
});
|
});
|
||||||
await waku.start();
|
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 waku.dial(await nwaku.getMultiaddrWithId());
|
||||||
await waitForRemotePeer(waku, [Protocols.Store]);
|
await waitForRemotePeer(waku, [Protocols.Store]);
|
||||||
|
|
||||||
|
@ -138,6 +136,8 @@ describe("Waku Store", () => {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
});
|
});
|
||||||
await waku.start();
|
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 waku.dial(await nwaku.getMultiaddrWithId());
|
||||||
await waitForRemotePeer(waku, [Protocols.Store]);
|
await waitForRemotePeer(waku, [Protocols.Store]);
|
||||||
|
|
||||||
|
@ -179,6 +179,8 @@ describe("Waku Store", () => {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
});
|
});
|
||||||
await waku.start();
|
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 waku.dial(await nwaku.getMultiaddrWithId());
|
||||||
await waitForRemotePeer(waku, [Protocols.Store]);
|
await waitForRemotePeer(waku, [Protocols.Store]);
|
||||||
|
|
||||||
|
@ -218,6 +220,8 @@ describe("Waku Store", () => {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
});
|
});
|
||||||
await waku.start();
|
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 waku.dial(await nwaku.getMultiaddrWithId());
|
||||||
await waitForRemotePeer(waku, [Protocols.Store]);
|
await waitForRemotePeer(waku, [Protocols.Store]);
|
||||||
|
|
||||||
|
@ -261,6 +265,8 @@ describe("Waku Store", () => {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
});
|
});
|
||||||
await waku.start();
|
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 waku.dial(await nwaku.getMultiaddrWithId());
|
||||||
await waitForRemotePeer(waku, [Protocols.Store]);
|
await waitForRemotePeer(waku, [Protocols.Store]);
|
||||||
|
|
||||||
|
@ -343,7 +349,11 @@ describe("Waku Store", () => {
|
||||||
log("Waku nodes created");
|
log("Waku nodes created");
|
||||||
|
|
||||||
await Promise.all([
|
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),
|
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),
|
waku2.dial(nimWakuMultiaddr),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -425,6 +435,8 @@ describe("Waku Store", () => {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
});
|
});
|
||||||
await waku.start();
|
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 waku.dial(await nwaku.getMultiaddrWithId());
|
||||||
await waitForRemotePeer(waku, [Protocols.Store]);
|
await waitForRemotePeer(waku, [Protocols.Store]);
|
||||||
|
|
||||||
|
@ -486,6 +498,8 @@ describe("Waku Store", () => {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
});
|
});
|
||||||
await waku.start();
|
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 waku.dial(await nwaku.getMultiaddrWithId());
|
||||||
await waitForRemotePeer(waku, [Protocols.Store]);
|
await waitForRemotePeer(waku, [Protocols.Store]);
|
||||||
|
|
||||||
|
@ -545,6 +559,8 @@ describe("Waku Store, custom pubsub topic", () => {
|
||||||
pubSubTopic: customPubSubTopic,
|
pubSubTopic: customPubSubTopic,
|
||||||
});
|
});
|
||||||
await waku.start();
|
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 waku.dial(await nwaku.getMultiaddrWithId());
|
||||||
await waitForRemotePeer(waku, [Protocols.Store]);
|
await waitForRemotePeer(waku, [Protocols.Store]);
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
|
import { waitForRemotePeer } from "@waku/core/lib/wait_for_remote_peer";
|
||||||
import { createLightNode, createPrivacyNode } from "@waku/create";
|
import { createLightNode, createPrivacyNode } from "@waku/create";
|
||||||
import type { WakuLight, WakuPrivacy } from "@waku/interfaces";
|
import type { WakuLight, WakuPrivacy } from "@waku/interfaces";
|
||||||
import { Protocols } from "@waku/interfaces";
|
import { Protocols } from "@waku/interfaces";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
|
|
||||||
import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../test_utils";
|
import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../src";
|
||||||
import { delay } from "../test_utils/delay";
|
import { delay } from "../src/delay";
|
||||||
|
|
||||||
import { waitForRemotePeer } from "./wait_for_remote_peer";
|
|
||||||
|
|
||||||
describe("Wait for remote peer", function () {
|
describe("Wait for remote peer", function () {
|
||||||
let waku1: WakuPrivacy;
|
let waku1: WakuPrivacy;
|
||||||
|
@ -37,6 +36,8 @@ describe("Wait for remote peer", function () {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
});
|
});
|
||||||
await waku1.start();
|
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 waku1.dial(multiAddrWithId);
|
||||||
await delay(1000);
|
await delay(1000);
|
||||||
await waitForRemotePeer(waku1, [Protocols.Relay]);
|
await waitForRemotePeer(waku1, [Protocols.Relay]);
|
||||||
|
@ -65,6 +66,8 @@ describe("Wait for remote peer", function () {
|
||||||
|
|
||||||
const waitPromise = waitForRemotePeer(waku1, [Protocols.Relay]);
|
const waitPromise = waitForRemotePeer(waku1, [Protocols.Relay]);
|
||||||
await delay(1000);
|
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 waku1.dial(multiAddrWithId);
|
||||||
await waitPromise;
|
await waitPromise;
|
||||||
|
|
||||||
|
@ -110,6 +113,8 @@ describe("Wait for remote peer", function () {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
});
|
});
|
||||||
await waku2.start();
|
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 waku2.dial(multiAddrWithId);
|
||||||
await delay(1000);
|
await delay(1000);
|
||||||
await waitForRemotePeer(waku2, [Protocols.Store]);
|
await waitForRemotePeer(waku2, [Protocols.Store]);
|
||||||
|
@ -139,6 +144,8 @@ describe("Wait for remote peer", function () {
|
||||||
await waku2.start();
|
await waku2.start();
|
||||||
const waitPromise = waitForRemotePeer(waku2, [Protocols.Store], 2000);
|
const waitPromise = waitForRemotePeer(waku2, [Protocols.Store], 2000);
|
||||||
await delay(1000);
|
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 waku2.dial(multiAddrWithId);
|
||||||
await waitPromise;
|
await waitPromise;
|
||||||
|
|
||||||
|
@ -165,6 +172,8 @@ describe("Wait for remote peer", function () {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
});
|
});
|
||||||
await waku2.start();
|
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 waku2.dial(multiAddrWithId);
|
||||||
await waitForRemotePeer(waku2, [Protocols.LightPush]);
|
await waitForRemotePeer(waku2, [Protocols.LightPush]);
|
||||||
|
|
||||||
|
@ -193,6 +202,8 @@ describe("Wait for remote peer", function () {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
});
|
});
|
||||||
await waku2.start();
|
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 waku2.dial(multiAddrWithId);
|
||||||
await waitForRemotePeer(waku2, [Protocols.Filter]);
|
await waitForRemotePeer(waku2, [Protocols.Filter]);
|
||||||
|
|
||||||
|
@ -222,6 +233,8 @@ describe("Wait for remote peer", function () {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
});
|
});
|
||||||
await waku2.start();
|
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 waku2.dial(multiAddrWithId);
|
||||||
await waitForRemotePeer(waku2);
|
await waitForRemotePeer(waku2);
|
||||||
|
|
||||||
|
@ -258,10 +271,12 @@ describe("Wait for remote peer", function () {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
});
|
});
|
||||||
await waku1.start();
|
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 waku1.dial(multiAddrWithId);
|
||||||
await waitForRemotePeer(waku1);
|
await waitForRemotePeer(waku1);
|
||||||
|
|
||||||
const peers = await waku1.relay.getMeshPeers();
|
const peers = waku1.relay.getMeshPeers();
|
||||||
|
|
||||||
const nimPeerId = multiAddrWithId.getPeerId();
|
const nimPeerId = multiAddrWithId.getPeerId();
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,15 @@
|
||||||
import type { PeerId } from "@libp2p/interface-peer-id";
|
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 { createLightNode, createPrivacyNode } from "@waku/create";
|
||||||
import type { Message, Waku, WakuLight, WakuPrivacy } from "@waku/interfaces";
|
import type { Message, Waku, WakuLight, WakuPrivacy } from "@waku/interfaces";
|
||||||
import { Protocols } from "@waku/interfaces";
|
import { Protocols } from "@waku/interfaces";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
|
|
||||||
import {
|
import { makeLogFileName, NOISE_KEY_1, NOISE_KEY_2, Nwaku } from "../src/";
|
||||||
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";
|
|
||||||
|
|
||||||
const TestContentTopic = "/test/1/waku/utf8";
|
const TestContentTopic = "/test/1/waku/utf8";
|
||||||
|
|
||||||
|
@ -44,6 +38,8 @@ describe("Waku Dial [node only]", function () {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
});
|
});
|
||||||
await waku.start();
|
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 waku.dial(multiAddrWithId);
|
||||||
await waitForRemotePeer(waku);
|
await waitForRemotePeer(waku);
|
||||||
|
|
||||||
|
@ -70,6 +66,8 @@ describe("Waku Dial [node only]", function () {
|
||||||
waku = await createLightNode({
|
waku = await createLightNode({
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
libp2p: {
|
libp2p: {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore TODO: uniformize usage of multiaddr lib across repos
|
||||||
peerDiscovery: [new PeerDiscoveryStaticPeers([multiAddrWithId])],
|
peerDiscovery: [new PeerDiscoveryStaticPeers([multiAddrWithId])],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -97,6 +95,8 @@ describe("Waku Dial [node only]", function () {
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
libp2p: {
|
libp2p: {
|
||||||
peerDiscovery: [
|
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()]),
|
new PeerDiscoveryStaticPeers([await nwaku.getMultiaddrWithId()]),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"target": "es2020",
|
"target": "es2020",
|
||||||
"outDir": "dist/",
|
|
||||||
"rootDir": "tests",
|
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"module": "esnext",
|
"module": "esnext",
|
||||||
|
@ -46,7 +44,7 @@
|
||||||
"types": ["node", "mocha"],
|
"types": ["node", "mocha"],
|
||||||
"typeRoots": ["node_modules/@types", "src/types"]
|
"typeRoots": ["node_modules/@types", "src/types"]
|
||||||
},
|
},
|
||||||
"include": ["tests"],
|
"include": ["tests", "src"],
|
||||||
"compileOnSave": false,
|
"compileOnSave": false,
|
||||||
"ts-node": {
|
"ts-node": {
|
||||||
"files": true
|
"files": true
|
||||||
|
|
Loading…
Reference in New Issue