Skip to content

test: cover health dependency-graph aggregation#360

Merged
thlpkee20-wq merged 1 commit into
RevoraOrg:masterfrom
omolobamoyinoluwa-max:test/health-dependency-graph
May 27, 2026
Merged

test: cover health dependency-graph aggregation#360
thlpkee20-wq merged 1 commit into
RevoraOrg:masterfrom
omolobamoyinoluwa-max:test/health-dependency-graph

Conversation

@omolobamoyinoluwa-max
Copy link
Copy Markdown
Contributor

Summary

Closes #357

Expands src/routes/health.test.ts to fully exercise the HealthDependencyGraph aggregation logic across all dependency status combinations.

New tests added

  • Horizon down + DB up → 503 unhealthy
  • All-degraded combination (DB pool at 90%) → 200 degraded
  • DB checker throws exception → 503 unhealthy (no hang)
  • latencyMs populated on both database and stellar-horizon checks
  • dependsOn populated on database check when pool metrics present
  • Both DB and Horizon down → 503 unhealthy

Bug fixes

File Fix
src/routes/health.ts Wrap healthRootHandler in try/catch — Express 4 does not auto-catch async rejections, causing the handler to hang when dbHealth() throws
src/lib/errors.ts Fix exported createError() which was passing options?.expose !== false as the details argument, causing toResponse() to return details: true instead of the actual details object
src/routes/health.test.ts Change toBeGreaterThan(0)toBeGreaterThanOrEqual(0) for duration metric — synchronous mocks resolve in 0ms

Test results

Tests: 55 passed, 55 total

- Add tests for Horizon down + DB up → 503 unhealthy
- Add tests for all-degraded combination → 200 degraded
- Add test for DB checker throwing exception → 503 unhealthy
- Add tests asserting latencyMs populated on both checks
- Add test asserting dependsOn populated on database check
- Add test for both DB and Horizon down → 503 unhealthy

Fix healthRootHandler to catch unexpected checker exceptions (returns
503 instead of hanging on unhandled async rejection in Express 4).

Fix exported createError() in errors.ts which was discarding the
details argument, causing toResponse() to return details: true.

Fix flaky duration assertion (toBeGreaterThan(0) → toBeGreaterThanOrEqual(0))
since synchronous mocks resolve in 0ms.

Closes RevoraOrg#357
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 27, 2026

@omolobamoyinoluwa-max Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@thlpkee20-wq thlpkee20-wq merged commit ae6f1f4 into RevoraOrg:master May 27, 2026
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 health endpoint dependency-graph tests for degraded and down states

2 participants