From 56f56d9265a3f4c28833f0da9ef21ef0802c1c91 Mon Sep 17 00:00:00 2001 From: mononaut Date: Wed, 3 Jun 2026 09:26:39 +0000 Subject: [PATCH] add cluster mempool idempotency test --- .../cluster-mempool/cluster-mempool.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/backend/src/__tests__/cluster-mempool/cluster-mempool.test.ts b/backend/src/__tests__/cluster-mempool/cluster-mempool.test.ts index 11d99b6eb..92895017b 100644 --- a/backend/src/__tests__/cluster-mempool/cluster-mempool.test.ts +++ b/backend/src/__tests__/cluster-mempool/cluster-mempool.test.ts @@ -95,6 +95,23 @@ describe('ClusterMempool', () => { expect(cm.getTxCount()).toBe(2); }); + it('should skip duplicate tx additions', () => { + const mempool = buildMempool([]); + const cm = new ClusterMempool(mempool); + const tx = makeTx(txid('a1'), 100, 100); + mempool[tx.txid] = tx; + + cm.applyMempoolChange({ + added: [tx, tx], + removed: [], + accelerations: {}, + }); + + expect(cm.getClusterCount()).toBe(1); + expect(cm.getTxCount()).toBe(1); + expect(cm.getBlocks(1)[0].txids).toEqual([tx.txid]); + }); + it('should handle removing a tx', () => { const parentId = txid('a1'); const childId = txid('a2');