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.
Test the audit event log filtering and capacity behavior
Description
The
eventLog,recordEvent, andGET /api/v1/eventsmachinery insrc/index.tssupportssinceandlimitquery params and caps the log atEVENT_LOG_CAP(10,000), shifting old entries out. Only thepair.registeredhappy path is tested. This issue covers thesincefilter, thelimitclamp, and the cap eviction.Requirements and context
StableRoute-Org/Stableroute-backendonly.sincetimestamp are returned and earlier ones are excluded.limitclamps to[1, EVENT_LOG_CAP]and returns the most recent N.pair.unregisteredandpair.refreshedevents are recorded by the relevant handlers.shiftboundary instead).Suggested execution
git checkout -b test/events-19-log-coveragesrc/__tests__/events.test.ts.Test and commit
npm run build,npm run lint, andnpm test.sincein the future,limit=0clamps to 1,limitover cap.npm testoutput and a coverage summary in the PR.Example commit message
test(events): cover audit log filtering, limit, and evictionGuidelines
Community & contribution rewards