diff --git a/packages/tests/src/node/node.ts b/packages/tests/src/node/node.ts index 2ec7dfc31f..3b4dac04b6 100644 --- a/packages/tests/src/node/node.ts +++ b/packages/tests/src/node/node.ts @@ -189,7 +189,7 @@ export class NimGoNode { return this.rpcCall("get_waku_v2_debug_v1_info", []); } - async sendSubscriptions( + async ensureSubscriptions( pubsubTopics: [string] = [DefaultPubSubTopic] ): Promise { this.checkProcess(); diff --git a/packages/tests/tests/filter/subscribe.node.spec.ts b/packages/tests/tests/filter/subscribe.node.spec.ts index 3681b2c682..1cc0510158 100644 --- a/packages/tests/tests/filter/subscribe.node.spec.ts +++ b/packages/tests/tests/filter/subscribe.node.spec.ts @@ -48,12 +48,12 @@ describe("Waku Filter V2: Subscribe", function () { waku = setup.waku; subscription = setup.subscription; messageCollector = setup.messageCollector; - }); - it("Subscribe and receive messages via lightPush", async function () { // Nwaku subscribe to the default pubsub topic - await nwaku.sendSubscriptions(); + await nwaku.ensureSubscriptions(); + }); + it("Subscribe and receive messages via lightPush", async function () { await subscription.subscribe([TestDecoder], messageCollector.callback); await waku.lightPush.send(TestEncoder, messagePayload); @@ -64,9 +64,6 @@ describe("Waku Filter V2: Subscribe", function () { }); it("Subscribe and receive messages via waku relay post", async function () { - // Nwaku subscribe to the default pubsub topic - await nwaku.sendSubscriptions(); - await subscription.subscribe([TestDecoder], messageCollector.callback); await delay(400); @@ -85,9 +82,6 @@ describe("Waku Filter V2: Subscribe", function () { }); it("Subscribe and receive 2 messages on the same topic", async function () { - // Nwaku subscribe to the default pubsub topic - await nwaku.sendSubscriptions(); - await subscription.subscribe([TestDecoder], messageCollector.callback); await waku.lightPush.send(TestEncoder, messagePayload); @@ -111,9 +105,6 @@ describe("Waku Filter V2: Subscribe", function () { }); it("Subscribe and receive messages on 2 different content topics", async function () { - // Nwaku subscribe to the default pubsub topic - await nwaku.sendSubscriptions(); - // Subscribe to the first content topic and send a message. await subscription.subscribe([TestDecoder], messageCollector.callback); await waku.lightPush.send(TestEncoder, messagePayload); diff --git a/packages/tests/tests/filter/unsubscribe.node.spec.ts b/packages/tests/tests/filter/unsubscribe.node.spec.ts index a89bcdab0c..478804d5e8 100644 --- a/packages/tests/tests/filter/unsubscribe.node.spec.ts +++ b/packages/tests/tests/filter/unsubscribe.node.spec.ts @@ -35,12 +35,12 @@ describe("Waku Filter V2: Unsubscribe", function () { waku = setup.waku; subscription = setup.subscription; messageCollector = setup.messageCollector; - }); - it("Unsubscribe 1 topic - node subscribed to 1 topic", async function () { // Nwaku subscribe to the default pubsub topic - await nwaku.sendSubscriptions(); + await nwaku.ensureSubscriptions(); + }); + it("Unsubscribe 1 topic - node subscribed to 1 topic", async function () { await subscription.subscribe([TestDecoder], messageCollector.callback); await waku.lightPush.send(TestEncoder, messagePayload); expect(await messageCollector.waitForMessages(1)).to.eq(true); @@ -57,9 +57,6 @@ describe("Waku Filter V2: Unsubscribe", function () { }); it("Unsubscribe 1 topic - node subscribed to 2 topics", async function () { - // Nwaku subscribe to the default pubsub topic - await nwaku.sendSubscriptions(); - // Subscribe to 2 topics and send messages await subscription.subscribe([TestDecoder], messageCollector.callback); const newContentTopic = "/test/2/waku-filter"; @@ -82,9 +79,6 @@ describe("Waku Filter V2: Unsubscribe", function () { }); it("Unsubscribe 2 topics - node subscribed to 2 topics", async function () { - // Nwaku subscribe to the default pubsub topic - await nwaku.sendSubscriptions(); - // Subscribe to 2 topics and send messages await subscription.subscribe([TestDecoder], messageCollector.callback); const newContentTopic = "/test/2/waku-filter"; @@ -107,9 +101,6 @@ describe("Waku Filter V2: Unsubscribe", function () { }); it("Unsubscribe topics the node is not subscribed to", async function () { - // Nwaku subscribe to the default pubsub topic - await nwaku.sendSubscriptions(); - // Subscribe to 1 topic and send message await subscription.subscribe([TestDecoder], messageCollector.callback); await waku.lightPush.send(TestEncoder, { payload: utf8ToBytes("M1") }); @@ -129,9 +120,6 @@ describe("Waku Filter V2: Unsubscribe", function () { }); it("Unsubscribes all - node subscribed to 1 topic", async function () { - // Nwaku subscribe to the default pubsub topic - await nwaku.sendSubscriptions(); - await subscription.subscribe([TestDecoder], messageCollector.callback); await waku.lightPush.send(TestEncoder, { payload: utf8ToBytes("M1") }); expect(await messageCollector.waitForMessages(1)).to.eq(true); @@ -148,9 +136,6 @@ describe("Waku Filter V2: Unsubscribe", function () { }); it("Unsubscribes all - node subscribed to 10 topics", async function () { - // Nwaku subscribe to the default pubsub topic - await nwaku.sendSubscriptions(); - // Subscribe to 10 topics and send message const topicCount = 10; const td = generateTestData(topicCount); diff --git a/packages/tests/tests/light_push.node.spec.ts b/packages/tests/tests/light_push.node.spec.ts index af8bf5c8ba..80133600fa 100644 --- a/packages/tests/tests/light_push.node.spec.ts +++ b/packages/tests/tests/light_push.node.spec.ts @@ -122,6 +122,9 @@ describe("Waku Light Push [node only] - custom pubsub topic", () => { beforeEach(async function () { this.timeout(15_000); [nwaku, waku] = await runNodes(this, customPubSubTopic); + + log("Waiting for nwaku to subscribe to pubsub topic"); + await nwaku.ensureSubscriptions([customPubSubTopic]); }); afterEach(async function () { @@ -136,9 +139,6 @@ describe("Waku Light Push [node only] - custom pubsub topic", () => { it("Push message", async function () { this.timeout(15_000); - log("Waiting for nwaku to subscribe to pubsub topic"); - await nwaku.sendSubscriptions([customPubSubTopic]); - const nimPeerId = await nwaku.getPeerId(); const messageText = "Light Push works!"; diff --git a/packages/tests/tests/relay.node.spec.ts b/packages/tests/tests/relay.node.spec.ts index 9b7015aaac..4d48f477f6 100644 --- a/packages/tests/tests/relay.node.spec.ts +++ b/packages/tests/tests/relay.node.spec.ts @@ -411,6 +411,9 @@ describe("Waku Relay [node only]", () => { await waku.dial(await nwaku.getMultiaddrWithId()); await waitForRemotePeer(waku, [Protocols.Relay]); + + // Nwaku subscribe to the default pubsub topic + await nwaku.ensureSubscriptions(); }); afterEach(async function () { @@ -437,9 +440,6 @@ describe("Waku Relay [node only]", () => { it("Publishes to nwaku", async function () { this.timeout(30000); - // Nwaku subscribe to the default pubsub topic - await nwaku.sendSubscriptions(); - const messageText = "This is a message"; await waku.relay.send(TestEncoder, { payload: utf8ToBytes(messageText) });