mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-03 22:33:07 +00:00
* run tests in parallel * small fixes * small fixes * fix setup of nodes * fix relay tests * fix Static Sharding: Running Nodes tests * try with 5 threads * try with 6 threads * use startWithRetries as default start * revert to 6 * set 10 jobs * revert to back to 6 * add CI info in readme
60 lines
1.7 KiB
TypeScript
60 lines
1.7 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";
|
|
|
|
import { tearDownNodes } from "../src";
|
|
|
|
describe("Peer Exchange", () => {
|
|
describe("Auto Discovery", function () {
|
|
let waku: LightNode;
|
|
|
|
afterEach(async function () {
|
|
this.timeout(15000);
|
|
await tearDownNodes([], waku);
|
|
});
|
|
|
|
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;
|
|
});
|
|
});
|
|
});
|
|
});
|