import { IdentifiableLiquidityPoolShard, MempoolEntry, MempoolInfoMap, } from '@saturnbtcio/pool-serde-sdk'; import { beforeEach, describe, expect, it } from 'vitest'; import { getMempoolEntryFromShard } from '../mempool'; const createDummyShard = ( params: Partial, ): IdentifiableLiquidityPoolShard => ({ poolPubkey: params.poolPubkey || 'pool1', runeUtxo: params.runeUtxo, btcUtxos: params.btcUtxos || [], liquidity: params.liquidity ?? 0n, protocolFeeOwed: params.protocolFeeOwed ?? 0n, lastBlockHeight: params.lastBlockHeight ?? 0n, timesUpdated: params.timesUpdated ?? 0n, kLast: params.kLast ?? 0n, kLastCounter: params.kLastCounter ?? 0n, pubkey: params.pubkey || 'dummyPubkey', utxo: params.utxo || 'dummyTxId', }); describe('getMempoolEntryFromShard', () => { let mempoolInfo: MempoolInfoMap; beforeEach(() => { mempoolInfo = new Map(); }); it('Returns the mempool entry if present', () => { const txId = 'tx1'; const shard = createDummyShard({ utxo: txId }); const mempoolEntry = { descendantCount: 3, ancestorCount: 1 }; mempoolInfo.set(txId, mempoolEntry as any); const entry = getMempoolEntryFromShard(shard, mempoolInfo); expect(entry).toEqual(mempoolEntry); }); it('Returns undefined if no mempool entry exists', () => { const txId = 'tx1'; const shard = createDummyShard({ utxo: txId }); const entry = getMempoolEntryFromShard(shard, mempoolInfo); expect(entry).toBeUndefined(); }); });