fix(tests): floating promises

This commit is contained in:
danisharora099 2024-01-29 17:14:20 +05:30
parent 8f652bfb8d
commit f2d64c80ac
No known key found for this signature in database
GPG Key ID: FBD2BF500037F135
3 changed files with 14 additions and 17 deletions

View File

@ -103,21 +103,18 @@ export class ServiceNodesFleet {
pubsubTopic?: string,
raw = false
): Promise<boolean> {
let relayMessagePromises: Promise<boolean>[];
const relayMessagePromises = this.nodes.map((node) => {
if (raw) {
relayMessagePromises = this.nodes.map((node) =>
node.rpcCall<boolean>("post_waku_v2_relay_v1_message", [
pubsubTopic && pubsubTopic,
return node.rpcCall<boolean>("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<void> {

View File

@ -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) {

View File

@ -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) {