mirror of
https://github.com/logos-messaging/logos-messaging-js.git
synced 2026-01-15 22:43:11 +00:00
Split the bootstrap logic in 2 different classes that implement the libp2p peer discovery class. This enables better tree shaking when not using the heaviest version (DNS Discovery). It also means using libp2p interface directly when customizing the peer discovery logic. Finally, the `default` method is still available via the `defaultBootstrap` option.
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import type { PeerId } from "@libp2p/interface-peer-id";
|
|
import { expect } from "chai";
|
|
|
|
import { createWaku } from "./create_waku";
|
|
import { Waku } from "./waku";
|
|
|
|
describe("Waku Dial", function () {
|
|
describe("Bootstrap [live data]", function () {
|
|
let waku: Waku;
|
|
|
|
afterEach(function () {
|
|
!!waku && waku.stop().catch((e) => console.log("Waku failed to stop", e));
|
|
});
|
|
|
|
before(function () {
|
|
if (process.env.CI) {
|
|
this.skip();
|
|
}
|
|
});
|
|
|
|
it("Enabling default [live data]", async function () {
|
|
// This test depends on fleets.status.im being online.
|
|
// This dependence must be removed once DNS discovery is implemented
|
|
this.timeout(20_000);
|
|
|
|
waku = await createWaku({
|
|
defaultBootstrap: true,
|
|
});
|
|
await waku.start();
|
|
|
|
const connectedPeerID: PeerId = await new Promise((resolve) => {
|
|
waku.libp2p.connectionManager.addEventListener(
|
|
"peer:connect",
|
|
(evt) => {
|
|
resolve(evt.detail.remotePeer);
|
|
}
|
|
);
|
|
});
|
|
|
|
expect(connectedPeerID).to.not.be.undefined;
|
|
});
|
|
});
|
|
});
|