add cluster mempool idempotency test

This commit is contained in:
mononaut 2026-06-03 09:26:39 +00:00
parent 35a501aefc
commit 56f56d9265
No known key found for this signature in database
GPG key ID: BFD16BE592A9CD8D

View file

@ -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');