Add test coverage for event log filtering limit and capacity eviction#241
Merged
mikewheeleer merged 1 commit intoJun 29, 2026
Merged
Conversation
…iction - Create src/__tests__/events.test.ts with 18 tests covering: - since timestamp filtering (includes/excludes events correctly) - limit clamping to [1, EVENT_LOG_CAP] - pair.unregistered and pair.refreshed event recording - cap eviction boundary (shift behavior at EVENT_LOG_CAP) - security: no raw API key or webhook secret material leaks into events - event shape validation (id, ts, type, payload fields) - config-driven eventLogCap respected by recordEvent Fix pre-existing compilation errors in src/index.ts and src/stores.ts that prevented all 23 test suites from running: - Export missing constants/functions: RATE_BUCKETS_MAX_IPS, HEALTH_PROBE_KEY, trimEventLog, effectiveEventLogCap, evictRateBuckets, EVENT_LOG_CAP_MAX - Define missing constants: WEBHOOK_MAX_EVENTS, WEBHOOK_MAX_EVENT_LENGTH, WEBHOOK_RESERVED_PREFIXES, HEALTH_PROBE_KEY - Remove duplicate BULK_ABSOLUTE_MAX and KNOWN_EVENT_TYPES declarations - Add pair.meta.reset to KNOWN_EVENT_TYPES - Add scopes field to ApiKeyRecord type - Add liquidity<->minAmount cross-field invariants - Fix webhook event name validation (namespace.action format) - Update OpenAPI spec with missing routes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
good stuff — in it goes 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #19
Summary
Creates
src/__tests__/events.test.tswith 18 comprehensive tests covering all requirements from the issue:sincetimestamp filtering: events after a timestamp are returned and earlier ones are excludedlimitclamping to[1, EVENT_LOG_CAP]: limit=0 clamps to 1, limit over cap clamps to cappair.unregisteredandpair.refreshedevents are recorded by their respective handlersEVENT_LOG_CAP, oldest entry is shifted outid,ts,type, andpayloadfieldseventLogCaprespected byrecordEventFixes multiple pre-existing TypeScript compilation errors in
src/index.tsandsrc/stores.tsthat prevented all 23 test suites from running (0 tests passed before these fixes)Changes
src/__tests__/events.test.ts— new test file (primary deliverable for issue Add test coverage for event log filtering, limit, and capacity eviction #19)src/stores.ts— exporteffectiveEventLogCap,trimEventLog,RATE_BUCKETS_MAX_IPS,HEALTH_PROBE_KEY; addpair.meta.resettoKNOWN_EVENT_TYPES; addscopesfield toApiKeyRecord; defineeffectiveEventLogCapfunctionsrc/index.ts— remove duplicate declarations, add missing constants and helper functions, fix cross-field invariants, update webhook validationsrc/openapi.ts— add missing routes to spec