mirror of https://github.com/waku-org/js-waku.git
fix: Use libp2p options passed to `createWaku`
This commit is contained in:
parent
ee12ec0ab5
commit
ba1c7b86ea
|
@ -90,25 +90,26 @@ export async function createWaku(options?: CreateOptions): Promise<Waku> {
|
|||
peerDiscovery.push(new Bootstrap(options?.bootstrap));
|
||||
}
|
||||
|
||||
// TODO: Use options
|
||||
const libp2pOpts = {
|
||||
transports: [new WebSockets({ filter: filterAll })],
|
||||
streamMuxers: [new Mplex()],
|
||||
pubsub: new WakuRelay(),
|
||||
connectionEncryption: [new Noise()],
|
||||
};
|
||||
const libp2pOpts = Object.assign(
|
||||
{
|
||||
transports: [new WebSockets({ filter: filterAll })],
|
||||
streamMuxers: [new Mplex()],
|
||||
pubsub: new WakuRelay(options),
|
||||
connectionEncryption: [new Noise()],
|
||||
},
|
||||
options?.libp2p ?? {}
|
||||
);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: modules property is correctly set thanks to voodoo
|
||||
const libp2p = await createLibp2p(libp2pOpts);
|
||||
|
||||
const wakuStore = new WakuStore(libp2p);
|
||||
const wakuLightPush = new WakuLightPush(libp2p);
|
||||
const wakuStore = new WakuStore(libp2p, options);
|
||||
const wakuLightPush = new WakuLightPush(libp2p, options);
|
||||
// TODO pass options
|
||||
const wakuFilter = new WakuFilter(libp2p);
|
||||
|
||||
await libp2p.start();
|
||||
|
||||
return new Waku({}, libp2p, wakuStore, wakuLightPush, wakuFilter);
|
||||
return new Waku(options ?? {}, libp2p, wakuStore, wakuLightPush, wakuFilter);
|
||||
}
|
||||
|
||||
export class Waku {
|
||||
|
|
|
@ -49,6 +49,7 @@ export class WakuFilter {
|
|||
{ method?: DecryptionMethod; contentTopics?: string[] }
|
||||
>;
|
||||
|
||||
// TODO: Accept options (pubsubtopic)
|
||||
constructor(public libp2p: Libp2p) {
|
||||
this.subscriptions = new Map();
|
||||
this.decryptionKeys = new Map();
|
||||
|
|
|
@ -71,10 +71,12 @@ describe("Waku Relay [node only]", () => {
|
|||
|
||||
it("Subscribe", async function () {
|
||||
log("Getting subscribers");
|
||||
const subscribers1 =
|
||||
waku1.libp2p.pubsub.getSubscribers(DefaultPubSubTopic);
|
||||
const subscribers2 =
|
||||
waku2.libp2p.pubsub.getSubscribers(DefaultPubSubTopic);
|
||||
const subscribers1 = waku1.libp2p.pubsub
|
||||
.getSubscribers(DefaultPubSubTopic)
|
||||
.map((p) => p.toString());
|
||||
const subscribers2 = waku2.libp2p.pubsub
|
||||
.getSubscribers(DefaultPubSubTopic)
|
||||
.map((p) => p.toString());
|
||||
|
||||
log("Asserting mutual subscription");
|
||||
expect(subscribers1).to.contain(waku2.libp2p.peerId.toString());
|
||||
|
|
Loading…
Reference in New Issue