diff --git a/src/chat/index.ts b/src/chat/index.ts index 7194524f5f..4d9ddaf9bb 100644 --- a/src/chat/index.ts +++ b/src/chat/index.ts @@ -26,11 +26,6 @@ const ChatContentTopic = 'dingpu'; console.log(`\t- ${address}`); }); - // TODO: Automatically subscribe, tracked with - // https://github.com/status-im/js-waku/issues/17 - await waku.relay.subscribe(); - console.log('Subscribed to waku relay'); - const rl = readline.createInterface({ input: process.stdin, output: process.stdout, diff --git a/src/lib/waku_relay/index.spec.ts b/src/lib/waku_relay/index.spec.ts index d85ece6a13..48d5ae08a6 100644 --- a/src/lib/waku_relay/index.spec.ts +++ b/src/lib/waku_relay/index.spec.ts @@ -34,9 +34,6 @@ describe('Waku Relay', () => { await waku1.dialWithMultiAddr(waku2.libp2p.peerId, waku2.libp2p.multiaddrs); - await waku1.relay.subscribe(); - await waku2.relay.subscribe(); - await Promise.all([ new Promise((resolve) => waku1.libp2p.pubsub.once('pubsub:subscription-change', () => @@ -107,7 +104,6 @@ describe('Waku Relay', () => { nimWaku = new NimWaku(makeLogFileName(this)); await nimWaku.start({ staticnode: multiAddrWithId }); - await waku.relay.subscribe(); await new Promise((resolve) => waku.libp2p.pubsub.once('gossipsub:heartbeat', resolve) ); @@ -180,8 +176,6 @@ describe('Waku Relay', () => { nimWaku = new NimWaku(this.test?.ctx?.currentTest?.title + ''); await nimWaku.start(); - await waku.relay.subscribe(); - await waku.dial(await nimWaku.getMultiaddrWithId()); // Wait for identify protocol to finish @@ -276,8 +270,6 @@ describe('Waku Relay', () => { waku2.dial(nimWakuMultiaddr), ]); - await Promise.all([waku1.relay.subscribe(), waku2.relay.subscribe()]); - await Promise.all([ new Promise((resolve) => waku1.libp2p.pubsub.once('gossipsub:heartbeat', resolve) diff --git a/src/lib/waku_relay/index.ts b/src/lib/waku_relay/index.ts index 018ca5fe20..58362b18bc 100644 --- a/src/lib/waku_relay/index.ts +++ b/src/lib/waku_relay/index.ts @@ -294,11 +294,8 @@ export class WakuRelayPubsub extends Gossipsub { // This class provides an interface to execute the waku relay protocol export class WakuRelay { - constructor(private pubsub: Pubsub) {} - - // At this stage we are always using the same topic so we do not pass it as a parameter - async subscribe() { - await this.pubsub.subscribe(constants.RelayDefaultTopic); + constructor(private pubsub: Pubsub) { + this.pubsub.subscribe(constants.RelayDefaultTopic); } async publish(message: WakuMessage) {