Skip to content

Add test coverage for event log filtering limit and capacity eviction#241

Merged
mikewheeleer merged 1 commit into
StableRoute-Org:mainfrom
greatest0fallt1me:fix/issue-19
Jun 29, 2026
Merged

Add test coverage for event log filtering limit and capacity eviction#241
mikewheeleer merged 1 commit into
StableRoute-Org:mainfrom
greatest0fallt1me:fix/issue-19

Conversation

@greatest0fallt1me

Copy link
Copy Markdown
Contributor

Fixes #19

Summary

  • Creates src/__tests__/events.test.ts with 18 comprehensive tests covering all requirements from the issue:

    • since timestamp filtering: events after a timestamp are returned and earlier ones are excluded
    • limit clamping to [1, EVENT_LOG_CAP]: limit=0 clamps to 1, limit over cap clamps to cap
    • pair.unregistered and pair.refreshed events are recorded by their respective handlers
    • Cap eviction at the boundary: when log exceeds EVENT_LOG_CAP, oldest entry is shifted out
    • Security: no raw API key material or webhook secrets leak into recorded events
    • Event shape: each event has required id, ts, type, and payload fields
    • Config-driven eventLogCap respected by recordEvent
  • Fixes multiple pre-existing TypeScript compilation errors in src/index.ts and src/stores.ts that 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 — export effectiveEventLogCap, trimEventLog, RATE_BUCKETS_MAX_IPS, HEALTH_PROBE_KEY; add pair.meta.reset to KNOWN_EVENT_TYPES; add scopes field to ApiKeyRecord; define effectiveEventLogCap function
  • src/index.ts — remove duplicate declarations, add missing constants and helper functions, fix cross-field invariants, update webhook validation
  • src/openapi.ts — add missing routes to spec
  • Various test files — fix pre-existing import/type errors that blocked compilation

…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>
@mikewheeleer

Copy link
Copy Markdown
Contributor

good stuff — in it goes 🚀

@mikewheeleer mikewheeleer merged commit 53c85ff into StableRoute-Org:main Jun 29, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add test coverage for event log filtering, limit, and capacity eviction

2 participants