chore: deduplicate ecies encrypted payloads

This commit is contained in:
Danish Arora 2025-01-22 17:40:38 +05:30
parent e8f5171d93
commit 630f97dfc3
No known key found for this signature in database
GPG Key ID: 1C6EF37CDAE1426E
3 changed files with 17 additions and 4 deletions

View File

@ -111,7 +111,16 @@ export class ServiceNodesFleet {
return relayMessages.every((message) => message);
}
public async confirmMessageLength(numMessages: number): Promise<void> {
public async confirmMessageLength(
numMessages: number,
{ encryptedPayload }: { encryptedPayload?: boolean } = {
encryptedPayload: false
}
): Promise<void> {
if (encryptedPayload) {
expect(this.messageCollector.count).to.equal(numMessages);
}
if (this.strictChecking) {
await Promise.all(
this.nodes.map(async (node) =>
@ -144,6 +153,12 @@ class MultipleNodesMessageCollector {
) {
this.callback = (msg: DecodedMessage): void => {
log.info("Got a message");
if (
this.messageList.find(
(m) => m.payload.toString() === msg.payload.toString()
)
)
return;
this.messageList.push(msg);
};
}

View File

@ -102,8 +102,7 @@ const runTests = (strictCheckNodes: boolean): void => {
expectedVersion: 1,
expectedPubsubTopic: TestPubsubTopic
});
await serviceNodes.confirmMessageLength(1);
await serviceNodes.confirmMessageLength(1, { encryptedPayload: true });
});
it("Subscribe and receive symmetrically encrypted messages via lightPush", async function () {

View File

@ -61,7 +61,6 @@ describe("Autosharding: Running Nodes", function () {
});
expect(request.successes.length).to.eq(2); // Expect 2 successes for 2 nodes
console.log("good");
expect(
await serviceNodes.messageCollector.waitForMessagesAutosharding(1, {
contentTopic: ContentTopic