Skip to content

Commit

Permalink
Merge branch 'master' into feat/px-default
Browse files Browse the repository at this point in the history
  • Loading branch information
danisharora099 authored Aug 11, 2023
2 parents 3646fdc + 7227657 commit 8d48380
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 13 deletions.
1 change: 0 additions & 1 deletion packages/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
"@types/dockerode": "^3.3.17",
"@types/mocha": "^10.0.1",
"@types/tail": "^2.2.1",
"@waku/sdk": "*",
"@typescript-eslint/eslint-plugin": "^5.57.0",
"@typescript-eslint/parser": "^5.62.0",
"@waku/dns-discovery": "*",
Expand Down
15 changes: 3 additions & 12 deletions packages/tests/tests/peer_exchange.node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
PeerExchangeCodec,
PeerExchangeDiscovery,
WakuPeerExchange,
wakuPeerExchangeDiscovery,
} from "@waku/peer-exchange";
import { createLightNode, Libp2pComponents } from "@waku/sdk";
import { expect } from "chai";
Expand Down Expand Up @@ -114,21 +113,13 @@ describe("Peer Exchange", () => {
discv5BootstrapNode: enr,
});

waku = await createLightNode({
libp2p: {
peerDiscovery: [wakuPeerExchangeDiscovery()],
},
});
const peerExchange = waku.libp2p.components["components"][
"peer-discovery-0"
] as PeerExchangeDiscovery;

waku = await createLightNode();
await waku.start();
const nwaku2Ma = await nwaku2.getMultiaddrWithId();

const nwaku2Ma = await nwaku2.getMultiaddrWithId();
await waku.libp2p.dialProtocol(nwaku2Ma, PeerExchangeCodec);

return peerExchange;
return new PeerExchangeDiscovery(waku.libp2p.components);
},
teardown: async () => {
await nwaku1?.stop();
Expand Down
55 changes: 55 additions & 0 deletions packages/tests/tests/waku.node.optional.spec.ts
Original file line number Diff line number Diff line change
@@ -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;
});
});

0 comments on commit 8d48380

Please sign in to comment.