mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-04-22 03:23:46 +00:00
* feat: enable/disable discoveries without defaultBootstrap: true * chore: rm .only * chore: don't redefine default discoveries object * chore: don't export default const from library * chore: rename discoveriesEnabled to discovery * fix: rename * address comments * chore: reset default Co-authored-by: Sasha <118575614+weboko@users.noreply.github.com> * chore: address comments * chore: update tests --------- Co-authored-by: Sasha <118575614+weboko@users.noreply.github.com>
59 lines
1.7 KiB
TypeScript
59 lines
1.7 KiB
TypeScript
import { PubsubTopic } from "@waku/interfaces";
|
|
import { expect } from "chai";
|
|
|
|
import { getPeerDiscoveries } from "./discovery.js";
|
|
|
|
describe("Default Peer Discoveries", () => {
|
|
const pubsubTopics: PubsubTopic[] = [];
|
|
|
|
it("should have no discoveries enabled by default", () => {
|
|
const discoveries = getPeerDiscoveries(pubsubTopics);
|
|
expect(discoveries.length).to.equal(0);
|
|
});
|
|
|
|
it("should enable all discoveries when explicitly set", () => {
|
|
const discoveries = getPeerDiscoveries(pubsubTopics, {
|
|
dns: true,
|
|
peerExchange: true,
|
|
localPeerCache: true
|
|
});
|
|
expect(discoveries.length).to.equal(3);
|
|
});
|
|
|
|
it("should enable only peerExchange and localPeerCache when dns is disabled", () => {
|
|
const discoveries = getPeerDiscoveries(pubsubTopics, {
|
|
dns: false,
|
|
peerExchange: true,
|
|
localPeerCache: true
|
|
});
|
|
expect(discoveries.length).to.equal(2);
|
|
});
|
|
|
|
it("should enable only dns and localPeerCache when peerExchange is disabled", () => {
|
|
const discoveries = getPeerDiscoveries(pubsubTopics, {
|
|
dns: true,
|
|
peerExchange: false,
|
|
localPeerCache: true
|
|
});
|
|
expect(discoveries.length).to.equal(2);
|
|
});
|
|
|
|
it("should enable only dns and peerExchange when localPeerCache is disabled", () => {
|
|
const discoveries = getPeerDiscoveries(pubsubTopics, {
|
|
dns: true,
|
|
peerExchange: true,
|
|
localPeerCache: false
|
|
});
|
|
expect(discoveries.length).to.equal(2);
|
|
});
|
|
|
|
it("should enable only localPeerCache when dns and peerExchange are disabled", () => {
|
|
const discoveries = getPeerDiscoveries(pubsubTopics, {
|
|
dns: false,
|
|
peerExchange: false,
|
|
localPeerCache: true
|
|
});
|
|
expect(discoveries.length).to.equal(1);
|
|
});
|
|
});
|