test(lnbits): exercise FIFO eviction in recordSeen (follow-up to #50) #54
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
packages/lnbits/src/client.tsships arecordSeen(set, value, max)helper for FIFO eviction on the two dedup caches landed in #50 (seenEventIds, capped at 1000;seenPaymentHashesper-sub, capped at 500). The current 11-test suite exercises hit/miss behaviour but doesn't exercise the eviction itself — a typo (set.size >= max→set.size > max, or worse) would let the cache grow unboundedly and no test would fail.Surfaced in the review of commit
8c4be01by the bitspire session.Fix shape
Two reasonable approaches:
SEEN_EVENT_IDS_MAX = 3). Cheap, but requires exporting the constant or monkey-patching.new LnbitsClient({ ..., dedupCaps: { events: 3, hashes: 3 } }). Cleaner, no production change beyond opening the seam.(2) is probably the right move; the cap shouldn't change between dev and prod, but a test seam keeps the test focused.
Test sketch
Same shape for the per-sub
seenPaymentHashescap.Out of scope
References
aiolabs/lamassu-next#50— the dedup work this tests.8c4be01.