Skip to content

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

@mikewheeleer

Description

@mikewheeleer

Test the audit event log filtering and capacity behavior

Description

The eventLog, recordEvent, and GET /api/v1/events machinery in src/index.ts supports since and limit query params and caps the log at EVENT_LOG_CAP (10,000), shifting old entries out. Only the pair.registered happy path is tested. This issue covers the since filter, the limit clamp, and the cap eviction.

Requirements and context

  • Repository scope: StableRoute-Org/Stableroute-backend only.
  • Assert events after a since timestamp are returned and earlier ones are excluded.
  • Assert limit clamps to [1, EVENT_LOG_CAP] and returns the most recent N.
  • Assert pair.unregistered and pair.refreshed events are recorded by the relevant handlers.
  • Cover the cap eviction at least logically (e.g. by exposing/parameterizing the cap, or documenting why a full 10k push is impractical and testing the shift boundary instead).

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/events-19-log-coverage
  • Implement changes
    • Write comprehensive tests in: create src/__tests__/events.test.ts.
    • Add documentation: none beyond test names.
    • Trigger registrations/unregistrations to populate the log deterministically.
    • Validate security: ensure no sensitive payload fields leak into events.
  • Test and commit

Test and commit

  • Run npm run build, npm run lint, and npm test.
  • Cover edge cases: since in the future, limit=0 clamps to 1, limit over cap.
  • Paste full npm test output and a coverage summary in the PR.

Example commit message

test(events): cover audit log filtering, limit, and eviction

Guidelines

  • Minimum 95 percent test coverage for impacted code.
  • Clear, reviewer-focused documentation.
  • Timeframe: 96 hours.

Community & contribution rewards

  • 💬 Join the StableRoute community on Discord for questions, reviews, and faster merges: https://discord.gg/37aCpusvx
  • ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions