From 682cc66232fe21b290c20ce145432cdd829158f9 Mon Sep 17 00:00:00 2001 From: Arseniy Klempner Date: Fri, 26 Apr 2024 17:55:04 -0700 Subject: [PATCH] fix: filter for wss in libp2p websocket transport --- packages/sdk/src/utils/libp2p.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/sdk/src/utils/libp2p.ts b/packages/sdk/src/utils/libp2p.ts index d8c9445e6d..bb199e40e3 100644 --- a/packages/sdk/src/utils/libp2p.ts +++ b/packages/sdk/src/utils/libp2p.ts @@ -5,7 +5,7 @@ import { identify } from "@libp2p/identify"; import { mplex } from "@libp2p/mplex"; import { ping } from "@libp2p/ping"; import { webSockets } from "@libp2p/websockets"; -import { all as filterAll } from "@libp2p/websockets/filters"; +import { all as filterAll, wss } from "@libp2p/websockets/filters"; import { wakuMetadata } from "@waku/core"; import { type CreateLibp2pOptions, @@ -64,11 +64,13 @@ export async function defaultLibp2p( ? { metadata: wakuMetadata(shardInfo) } : {}; + const filter = process?.env?.NODE_ENV === "test" ? filterAll : wss; + return createLibp2p({ connectionManager: { minConnections: 1 }, - transports: [webSockets({ filter: filterAll })], + transports: [webSockets({ filter })], streamMuxers: [mplex()], connectionEncryption: [noise()], ...options,