From 1d1c7a28a899b2477ead9b5c302e7bc6e2e313fe Mon Sep 17 00:00:00 2001 From: fbarbu15 Date: Tue, 10 Oct 2023 08:51:41 +0300 Subject: [PATCH] updated wrong cursor test --- .../tests/tests/store/cursor.node.spec.ts | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/packages/tests/tests/store/cursor.node.spec.ts b/packages/tests/tests/store/cursor.node.spec.ts index 39bd940f8e..d823492374 100644 --- a/packages/tests/tests/store/cursor.node.spec.ts +++ b/packages/tests/tests/store/cursor.node.spec.ts @@ -169,8 +169,7 @@ describe("Waku Store, cursor", function () { } }); - // PubsubTopic is ignored in the cursor: https://github.com/waku-org/js-waku/pull/1640 - it.skip("Passing cursor with wrong pubSubTopic", async function () { + it("Passing cursor with wrong pubSubTopic", async function () { await sendMessages(nwaku, totalMsgs, TestContentTopic, DefaultPubSubTopic); waku = await startAndConnectLightNode(nwaku); @@ -180,18 +179,25 @@ describe("Waku Store, cursor", function () { messages.push(msg as DecodedMessage); } } - const cursor = await createCursor(messages[5], customPubSubTopic); + messages[5].pubSubTopic = customPubSubTopic; + const cursor = await createCursor(messages[5]); - const messagesAfterCursor: DecodedMessage[] = []; - for await (const page of waku.store.queryGenerator([TestDecoder], { - cursor - })) { - for await (const msg of page.reverse()) { - if (msg) { - messagesAfterCursor.push(msg as DecodedMessage); - } + try { + for await (const page of waku.store.queryGenerator([TestDecoder], { + cursor + })) { + page; + } + throw new Error("Cursor with wrong pubsubtopic was accepted"); + } catch (err) { + if ( + !(err instanceof Error) || + !err.message.includes( + `Cursor pubsub topic (${customPubSubTopic}) does not match decoder pubsub topic (${DefaultPubSubTopic})` + ) + ) { + throw err; } } - expect(messagesAfterCursor.length).be.eql(0); }); });