fix: non duplicacy should happen in application-specific scenario

This commit is contained in:
Danish Arora 2025-01-22 18:29:04 +05:30
parent b7c60a2332
commit 1932ef5fdc
No known key found for this signature in database
GPG Key ID: 1C6EF37CDAE1426E
2 changed files with 11 additions and 11 deletions

View File

@ -118,7 +118,14 @@ export class ServiceNodesFleet {
}
): Promise<void> {
if (encryptedPayload) {
expect(this.messageCollector.count).to.equal(numMessages);
const filteredMessageList = Array.from(
new Set(
this.messageCollector.messageList
.filter((msg) => msg.payload?.toString)
.map((msg) => msg.payload.toString())
)
);
expect(filteredMessageList.length).to.equal(numMessages);
return;
}
@ -146,7 +153,7 @@ export class ServiceNodesFleet {
class MultipleNodesMessageCollector {
public callback: (msg: DecodedMessage) => void = () => {};
protected messageList: Array<DecodedMessage> = [];
public readonly messageList: Array<DecodedMessage> = [];
public constructor(
private messageCollectors: MessageCollector[],
private relayNodes?: ServiceNode[],
@ -154,14 +161,7 @@ class MultipleNodesMessageCollector {
) {
this.callback = (msg: DecodedMessage): void => {
log.info("Got a message");
// Only add message if we haven't seen it before
if (
!this.messageList.find(
(m) => m.payload.toString() === msg.payload.toString()
)
) {
this.messageList.push(msg);
}
this.messageList.push(msg);
};
}

View File

@ -135,7 +135,7 @@ const runTests = (strictCheckNodes: boolean): void => {
expectedPubsubTopic: TestPubsubTopic
});
await serviceNodes.confirmMessageLength(1);
await serviceNodes.confirmMessageLength(1, { encryptedPayload: true });
});
it("Subscribe and receive messages via waku relay post", async function () {