mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-08 08:43:09 +00:00
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
import { bootstrap } from "@libp2p/bootstrap";
|
|
import { waitForRemotePeer } from "@waku/core";
|
|
import {
|
|
Fleet,
|
|
getPredefinedBootstrapNodes,
|
|
} from "@waku/core/lib/predefined_bootstrap_nodes";
|
|
import { createLightNode } from "@waku/create";
|
|
import type { LightNode, PeerExchangeResponse } from "@waku/interfaces";
|
|
import { Protocols } from "@waku/interfaces";
|
|
import { expect } from "chai";
|
|
|
|
describe("Peer Exchange: Node", () => {
|
|
let waku: LightNode;
|
|
afterEach(async function () {
|
|
!!waku && waku.stop().catch((e) => console.log("Waku failed to stop", e));
|
|
});
|
|
|
|
it("Test Fleet: Queries successfully [Live Data]", async function () {
|
|
this.timeout(150_000);
|
|
|
|
// skipping in CI as this test demonstrates Peer Exchange working with the test fleet
|
|
// but not with locally run nwaku nodes
|
|
if (process.env.ci) {
|
|
this.skip();
|
|
}
|
|
|
|
const waku = await createLightNode({
|
|
libp2p: {
|
|
peerDiscovery: [
|
|
bootstrap({ list: getPredefinedBootstrapNodes(Fleet.Test) }),
|
|
],
|
|
},
|
|
});
|
|
|
|
await waku.start();
|
|
|
|
await waitForRemotePeer(waku, [Protocols.PeerExchange]);
|
|
|
|
let receivedCallback = false;
|
|
const numPeersToRequest = 3;
|
|
const callback = (response: PeerExchangeResponse): void => {
|
|
receivedCallback = true;
|
|
expect(response.peerInfos.length).to.be.greaterThan(0);
|
|
expect(response.peerInfos.length).to.be.lessThanOrEqual(
|
|
numPeersToRequest
|
|
);
|
|
|
|
expect(response.peerInfos[0].ENR).to.not.be.null;
|
|
};
|
|
|
|
await waku.peerExchange.query(
|
|
{
|
|
numPeers: numPeersToRequest,
|
|
},
|
|
callback
|
|
);
|
|
|
|
expect(receivedCallback).to.be.true;
|
|
});
|
|
});
|