diff --git a/packages/tests/tests/store/multiple_pubsub.spec.ts b/packages/tests/tests/store/multiple_pubsub.spec.ts index bf95df9e95..8ce77d22f6 100644 --- a/packages/tests/tests/store/multiple_pubsub.spec.ts +++ b/packages/tests/tests/store/multiple_pubsub.spec.ts @@ -1,8 +1,4 @@ -import { - createDecoder, - DefaultPubSubTopic, - waitForRemotePeer -} from "@waku/core"; +import { DefaultPubSubTopic, waitForRemotePeer } from "@waku/core"; import type { IMessage, LightNode } from "@waku/interfaces"; import { createLightNode, Protocols } from "@waku/sdk"; import { expect } from "chai"; @@ -15,6 +11,9 @@ import { } from "../../src/index.js"; import { + customContentTopic, + customPubSubTopic, + customTestDecoder, processMessages, sendMessages, startAndConnectLightNode, @@ -23,10 +22,6 @@ import { totalMsgs } from "./utils.js"; -const customContentTopic = "/test/2/waku-store/utf8"; -const customPubSubTopic = "/waku/2/custom-dapp/proto"; -const customTestDecoder = createDecoder(customContentTopic, customPubSubTopic); - describe("Waku Store, custom pubsub topic", function () { this.timeout(15000); let waku: LightNode; diff --git a/packages/tests/tests/store/store.node.spec.ts b/packages/tests/tests/store/store.node.spec.ts index 02a962aa9b..699ce83ebd 100644 --- a/packages/tests/tests/store/store.node.spec.ts +++ b/packages/tests/tests/store/store.node.spec.ts @@ -33,6 +33,7 @@ import { import { areUint8ArraysEqual } from "../../src/utils.js"; import { + customContentTopic, log, messageText, processMessages, @@ -100,6 +101,8 @@ describe("Waku Store", function () { [TestDecoder], DefaultPubSubTopic ); + + // checking that all message sent were retrieved TEST_STRING.forEach((testItem) => { expect( messageCollector.hasMessage(TestContentTopic, testItem["value"]) @@ -107,7 +110,36 @@ describe("Waku Store", function () { }); }); - it("Query generator for multiple messages with different message content topic format", async function () { + it("Query generator for multiple messages with multiple decoders", async function () { + await nwaku.sendMessage( + NimGoNode.toMessageRpcQuery({ + payload: utf8ToBytes("M1"), + contentTopic: TestContentTopic + }), + DefaultPubSubTopic + ); + await nwaku.sendMessage( + NimGoNode.toMessageRpcQuery({ + payload: utf8ToBytes("M2"), + contentTopic: customContentTopic + }), + DefaultPubSubTopic + ); + waku = await startAndConnectLightNode(nwaku); + + const secondDecoder = createDecoder(customContentTopic, DefaultPubSubTopic); + + const messageCollector = new MessageCollector(); + messageCollector.list = await processMessages( + waku, + [TestDecoder, secondDecoder], + DefaultPubSubTopic + ); + expect(messageCollector.hasMessage(TestContentTopic, "M1")).to.eq(true); + expect(messageCollector.hasMessage(customContentTopic, "M2")).to.eq(true); + }); + + it("Query generator for multiple messages with different content topic format", async function () { for (const testItem of TEST_STRING) { expect( await nwaku.sendMessage( @@ -131,7 +163,9 @@ describe("Waku Store", function () { const _promises = msgPromises.map(async (promise) => { const msg = await promise; if (msg) { - areUint8ArraysEqual(msg.payload, utf8ToBytes(messageText)); + expect( + areUint8ArraysEqual(msg.payload, utf8ToBytes(messageText)) + ).to.eq(true); } }); diff --git a/packages/tests/tests/store/utils.ts b/packages/tests/tests/store/utils.ts index 40af75a5e6..1b731fa8ac 100644 --- a/packages/tests/tests/store/utils.ts +++ b/packages/tests/tests/store/utils.ts @@ -18,6 +18,12 @@ export const log = debug("waku:test:store"); export const TestContentTopic = "/test/1/waku-store/utf8"; export const TestEncoder = createEncoder({ contentTopic: TestContentTopic }); export const TestDecoder = createDecoder(TestContentTopic); +export const customContentTopic = "/test/2/waku-store/utf8"; +export const customPubSubTopic = "/waku/2/custom-dapp/proto"; +export const customTestDecoder = createDecoder( + customContentTopic, + customPubSubTopic +); export const totalMsgs = 20; export const messageText = "Store Push works!";