Skip to content

Commit

Permalink
chore: deduplicate ecies encrypted payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
danisharora099 committed Jan 22, 2025
1 parent c48d1b8 commit ac4edd9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
17 changes: 16 additions & 1 deletion packages/tests/src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down Expand Up @@ -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);
};
}
Expand Down
3 changes: 1 addition & 2 deletions packages/tests/tests/filter/subscribe.node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
1 change: 0 additions & 1 deletion packages/tests/tests/sharding/auto_sharding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ac4edd9

Please sign in to comment.