mirror of
https://github.com/logos-messaging/logos-messaging-js.git
synced 2026-01-19 08:23:11 +00:00
* chore: update noise * update: package.lock * update: @chainsafe/libp2p-gossipsub * rm unwanted libp2p interface deps & bump up libp2p * refactor code for new deps * update: new package.lock * setup prettier, refactor eslint and rm trailing commas * update package.lock * fix build * import type for interface * fix imports for merge * update typedoc exports * add: CustomEvent import * use new libp2p interface * add aegir as dev dep for tests
57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
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;
|
|
});
|
|
});
|
|
});
|
|
});
|