From f2d64c80ac35914743090984742b58b5a1fd9933 Mon Sep 17 00:00:00 2001 From: danisharora099 Date: Mon, 29 Jan 2024 17:14:20 +0530 Subject: [PATCH] fix(tests): floating promises --- packages/tests/src/lib/index.ts | 23 ++++++++----------- .../tests/tests/store/cursor.node.spec.ts | 2 +- .../tests/store/error_handling.node.spec.ts | 6 ++--- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/packages/tests/src/lib/index.ts b/packages/tests/src/lib/index.ts index 550b77f88b..474f520483 100644 --- a/packages/tests/src/lib/index.ts +++ b/packages/tests/src/lib/index.ts @@ -103,21 +103,18 @@ export class ServiceNodesFleet { pubsubTopic?: string, raw = false ): Promise { - let relayMessagePromises: Promise[]; - if (raw) { - relayMessagePromises = this.nodes.map((node) => - node.rpcCall("post_waku_v2_relay_v1_message", [ - pubsubTopic && pubsubTopic, + const relayMessagePromises = this.nodes.map((node) => { + if (raw) { + return node.rpcCall("post_waku_v2_relay_v1_message", [ + pubsubTopic ?? pubsubTopic, message - ]) - ); - } else { - relayMessagePromises = this.nodes.map((node) => - node.sendMessage(message, pubsubTopic) - ); - } + ]); + } + return node.sendMessage(message, pubsubTopic); + }); + const relayMessages = await Promise.all(relayMessagePromises); - return relayMessages.every((message) => message); + return relayMessages.every(Boolean); // More concise way to check all true } async confirmMessageLength(numMessages: number): Promise { diff --git a/packages/tests/tests/store/cursor.node.spec.ts b/packages/tests/tests/store/cursor.node.spec.ts index f54b75e00a..b5d8ee0c4f 100644 --- a/packages/tests/tests/store/cursor.node.spec.ts +++ b/packages/tests/tests/store/cursor.node.spec.ts @@ -191,7 +191,7 @@ describe("Waku Store, cursor", function () { for await (const page of waku.store.queryGenerator([TestDecoder], { cursor })) { - page; + void page; } throw new Error("Cursor with wrong pubsubtopic was accepted"); } catch (err) { diff --git a/packages/tests/tests/store/error_handling.node.spec.ts b/packages/tests/tests/store/error_handling.node.spec.ts index 8f09ff0a60..354f795bc2 100644 --- a/packages/tests/tests/store/error_handling.node.spec.ts +++ b/packages/tests/tests/store/error_handling.node.spec.ts @@ -39,7 +39,7 @@ describe("Waku Store, error handling", function () { for await (const msgPromises of waku.store.queryGenerator([ customDecoder1 ])) { - msgPromises; + void msgPromises; } throw new Error("QueryGenerator was successful but was expected to fail"); } catch (err) { @@ -60,7 +60,7 @@ describe("Waku Store, error handling", function () { TestDecoder, customDecoder1 ])) { - msgPromises; + void msgPromises; } throw new Error("QueryGenerator was successful but was expected to fail"); } catch (err) { @@ -78,7 +78,7 @@ describe("Waku Store, error handling", function () { it("Query Generator, No Decoder", async function () { try { for await (const msgPromises of waku.store.queryGenerator([])) { - msgPromises; + void msgPromises; } throw new Error("QueryGenerator was successful but was expected to fail"); } catch (err) {