From b8c63355a54446973451a21356d5c70e5de6ce10 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Wed, 10 Mar 2021 16:25:54 +1100 Subject: [PATCH] Ensure waku relay node does not use a sub protocol At the moment we do not assert that we publish messages over waku relay protocol (not sure this assertion is possible). By asserting we do not register any sub (pubsub, gossipsub, floodsub) protocols, we can be (more) confident that this protocols are not be used behind the scenes. --- src/lib/node.spec.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lib/node.spec.ts b/src/lib/node.spec.ts index d489865368..8058c3d068 100644 --- a/src/lib/node.spec.ts +++ b/src/lib/node.spec.ts @@ -44,6 +44,13 @@ test('Register waku relay protocol', async (t) => { t.truthy(protocols.findIndex((value) => value == CODEC)); }); +test('Does not register any sub protocol', async (t) => { + const node = await createNode(); + + const protocols = Array.from(node.upgrader.protocols.keys()); + t.truthy(protocols.findIndex((value) => value.match(/sub/))); +}); + function waitForNextData(pubsub: Pubsub): Promise { return new Promise((resolve) => { pubsub.once(TOPIC, resolve);