Skip to content

Feature/pause state coverage#1291

Merged
Baskarayelu merged 6 commits into
QuickLendX:mainfrom
mikkyvans0-source:feature/pause-state-coverage
Jun 3, 2026
Merged

Feature/pause state coverage#1291
Baskarayelu merged 6 commits into
QuickLendX:mainfrom
mikkyvans0-source:feature/pause-state-coverage

Conversation

@mikkyvans0-source
Copy link
Copy Markdown
Contributor

@mikkyvans0-source mikkyvans0-source commented Jun 2, 2026

Pull Request Template

Closes #1093

Summary
This work adds full pause-state coverage for the emergency circuit breaker. It's on branch feature/pause-state-coverage.

What I found
The real contract lives in quicklendx-contracts/, not the root src/ (which is a separate arithmetic-only crate with a different pause model). All work targets the real contract.

Security bug found and fixed: While validating that no mutating path ignores the pause flag, I found that process_partial_payment and its alias make_payment did not call require_not_paused — they bypassed the circuit breaker entirely. A payment could be processed while the protocol was supposedly frozen. The guard was added to both.

Changes (committed in 2dc4b9d + refactor 4bd8c4c)
lib.rs — added the missing pause guard to process_partial_payment/make_payment; added /// pause-check notes to store_invoice, place_bid, accept_bid_and_fund, settle_invoice.
test_pause.rs — 9 new tests: blocked-while-paused for place_bid, process_partial_payment, make_payment; unpause-recovery for all five entrypoints; and a mid-lifecycle freeze/resume test. Funded-invoice tests use a token-backed SAC fixture matching the e2e harness.
operations.md — expanded the Pause section with the authoritative pause matrix (each row → its blocked + recovery test) and a circuit-breaker invariant note

mikkyvans0-source and others added 5 commits June 2, 2026 12:02
The app exposed a single flat /health that always returned status: ok, with
no distinction between liveness (process up) and readiness (dependencies
healthy). Orchestrators could therefore route traffic to instances that were
up but unable to serve.

Split the signal into two probes, mounted at the root and unauthenticated so
orchestrators can reach them:

- /health, /livez  — cheap, dependency-free liveness check (always 200).
- /readyz          — readiness check that probes DB connectivity
  (pingDatabase), ingest lag (lagMonitor), and webhook queue health, honours
  maintenance mode, and returns 503 when not ready. Reuses the SubStatus /
  degradation pattern from the monitoring route: "degraded" stays in rotation,
  "unavailable" fails readiness.

Add a pingDatabase() helper (SELECT 1 round-trip), readiness.test.ts covering
DB-down, critical lag, maintenance mode, partial failure and queue-saturation
edge cases plus information-leak checks, and docs/health.md documenting probe
semantics. Probe responses expose only coarse status enums — no hostnames,
versions, ledger numbers, or error messages.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The app exposed a single flat /health that always returned status: ok, with
no distinction between liveness (process up) and readiness (dependencies
healthy). Orchestrators could therefore route traffic to instances that were
up but unable to serve.

Split the signal into two probes, mounted at the root and unauthenticated so
orchestrators can reach them:

- /health, /livez  — cheap, dependency-free liveness check (always 200).
- /readyz          — readiness check that probes DB connectivity
  (pingDatabase), ingest lag (lagMonitor), and webhook queue health, honours
  maintenance mode, and returns 503 when not ready. Reuses the SubStatus /
  degradation pattern from the monitoring route: "degraded" stays in rotation,
  "unavailable" fails readiness.

Add a pingDatabase() helper (SELECT 1 round-trip), readiness.test.ts covering
DB-down, critical lag, maintenance mode, partial failure and queue-saturation
edge cases plus information-leak checks, and docs/health.md documenting probe
semantics. Probe responses expose only coarse status enums — no hostnames,
versions, ledger numbers, or error messages.
…dency-probes' of https://github.com/mikkyvans0-source/quicklendx-protocol into Backend--Add-health/readiness/liveness-split-with-dependency-probes
…olds and add corresponding unit tests and documentation
…comprehensive documentation and regression tests
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Jun 2, 2026

@mikkyvans0-source 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

Consolidates the funded-invoice setup in test_pause.rs onto a single
token-backed `fund_invoice` helper that registers a real Stellar Asset
Contract with funded, pre-approved balances, mirroring the e2e fixture.
This is required because accept_bid_and_fund, settle_invoice, and a
completing process_partial_payment move real value through transfer_funds.

Also:
- Add test_pause_blocks_make_payment_alias so the make_payment alias is
  covered by the circuit-breaker matrix alongside process_partial_payment.
- Fix bid setup to use expected_return (1100) > bid_amount (1000), which
  validate_bid requires.
- Remove the now-redundant setup_funded_with_token helper.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Baskarayelu Baskarayelu merged commit 554e1b1 into QuickLendX:main Jun 3, 2026
2 of 4 checks passed
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 pause-state coverage ensuring all mutating entrypoints reject while paused

2 participants