fix: return early if expect passes

This commit is contained in:
Danish Arora 2025-01-22 18:01:04 +05:30
parent a8e338f985
commit 9127637151
No known key found for this signature in database
GPG Key ID: 1C6EF37CDAE1426E

View File

@ -119,6 +119,7 @@ export class ServiceNodesFleet {
): Promise<void> { ): Promise<void> {
if (encryptedPayload) { if (encryptedPayload) {
expect(this.messageCollector.count).to.equal(numMessages); expect(this.messageCollector.count).to.equal(numMessages);
return;
} }
if (this.strictChecking) { if (this.strictChecking) {
@ -153,13 +154,14 @@ class MultipleNodesMessageCollector {
) { ) {
this.callback = (msg: DecodedMessage): void => { this.callback = (msg: DecodedMessage): void => {
log.info("Got a message"); log.info("Got a message");
// Only add message if we haven't seen it before
if ( if (
this.messageList.find( !this.messageList.find(
(m) => m.payload.toString() === msg.payload.toString() (m) => m.payload.toString() === msg.payload.toString()
) )
) ) {
return; this.messageList.push(msg);
this.messageList.push(msg); }
}; };
} }