mirror of
https://github.com/logos-messaging/logos-delivery-js.git
synced 2026-03-16 22:53:29 +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.
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import { expect } from "chai";
|
|
|
|
import { getPseudoRandomSubset } from "../random_subset";
|
|
|
|
describe("Discovery", () => {
|
|
it("returns all values when wanted number matches available values", function () {
|
|
const values = ["a", "b", "c"];
|
|
|
|
const res = getPseudoRandomSubset(values, 3);
|
|
|
|
expect(res.length).to.eq(3);
|
|
expect(res.includes("a")).to.be.true;
|
|
expect(res.includes("b")).to.be.true;
|
|
expect(res.includes("c")).to.be.true;
|
|
});
|
|
|
|
it("returns all values when wanted number is greater than available values", function () {
|
|
const values = ["a", "b", "c"];
|
|
|
|
const res = getPseudoRandomSubset(values, 5);
|
|
|
|
expect(res.length).to.eq(3);
|
|
expect(res.includes("a")).to.be.true;
|
|
expect(res.includes("b")).to.be.true;
|
|
expect(res.includes("c")).to.be.true;
|
|
});
|
|
|
|
it("returns a subset of values when wanted number is lesser than available values", function () {
|
|
const values = ["a", "b", "c"];
|
|
|
|
const res = getPseudoRandomSubset(values, 2);
|
|
|
|
expect(res.length).to.eq(2);
|
|
});
|
|
});
|