mirror of
https://github.com/waku-org/js-waku.git
synced 2025-02-19 23:58:11 +00:00
feat(tests): several enrtree + static multiaddr for bootstrap (#1448)
* add: test for multi enrtree + static multiaddr * wrap up test * rm: only * move test to optional file * fix: build * fix: test expect * rm: only
This commit is contained in:
parent
462d614701
commit
7227657d69
@ -70,7 +70,6 @@
|
|||||||
"@types/dockerode": "^3.3.17",
|
"@types/dockerode": "^3.3.17",
|
||||||
"@types/mocha": "^10.0.1",
|
"@types/mocha": "^10.0.1",
|
||||||
"@types/tail": "^2.2.1",
|
"@types/tail": "^2.2.1",
|
||||||
"@waku/sdk": "*",
|
|
||||||
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
||||||
"@typescript-eslint/parser": "^5.62.0",
|
"@typescript-eslint/parser": "^5.62.0",
|
||||||
"@waku/dns-discovery": "*",
|
"@waku/dns-discovery": "*",
|
||||||
|
55
packages/tests/tests/waku.node.optional.spec.ts
Normal file
55
packages/tests/tests/waku.node.optional.spec.ts
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import { bootstrap } from "@libp2p/bootstrap";
|
||||||
|
import { enrTree, wakuDnsDiscovery } from "@waku/dns-discovery";
|
||||||
|
import { LightNode } from "@waku/interfaces";
|
||||||
|
import { createLightNode } from "@waku/sdk";
|
||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { makeLogFileName, NimGoNode } from "../src/index.js";
|
||||||
|
|
||||||
|
describe("Use static and several ENR trees for bootstrap", function () {
|
||||||
|
let waku: LightNode;
|
||||||
|
let nwaku: NimGoNode;
|
||||||
|
|
||||||
|
afterEach(async function () {
|
||||||
|
!!nwaku && (await nwaku.stop());
|
||||||
|
!!waku && waku.stop().catch((e) => console.log("Waku failed to stop", e));
|
||||||
|
});
|
||||||
|
|
||||||
|
it("", async function () {
|
||||||
|
this.timeout(10_000);
|
||||||
|
|
||||||
|
nwaku = new NimGoNode(makeLogFileName(this));
|
||||||
|
await nwaku.start();
|
||||||
|
const multiAddrWithId = await nwaku.getMultiaddrWithId();
|
||||||
|
|
||||||
|
const NODE_REQUIREMENTS = {
|
||||||
|
store: 3,
|
||||||
|
lightPush: 3,
|
||||||
|
filter: 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
waku = await createLightNode({
|
||||||
|
libp2p: {
|
||||||
|
peerDiscovery: [
|
||||||
|
bootstrap({ list: [multiAddrWithId.toString()] }),
|
||||||
|
wakuDnsDiscovery(
|
||||||
|
[enrTree["PROD"], enrTree["TEST"]],
|
||||||
|
NODE_REQUIREMENTS
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
await waku.start();
|
||||||
|
|
||||||
|
const peersDiscovered = await waku.libp2p.peerStore.all();
|
||||||
|
|
||||||
|
// 3 from DNS Disc, 1 from bootstrap
|
||||||
|
expect(peersDiscovered.length).to.eq(3 + 1);
|
||||||
|
// should also have the bootstrap peer
|
||||||
|
expect(
|
||||||
|
peersDiscovered.find(
|
||||||
|
(p) => p.id.toString() === multiAddrWithId.getPeerId()?.toString()
|
||||||
|
)
|
||||||
|
).to.not.be.undefined;
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user