Skip to content

test(utils): add 100% coverage unit tests for retryOperation (MEN-39)#136

Closed
mento-val wants to merge 3 commits intomainfrom
qa/men-39-retry-operation-tests
Closed

test(utils): add 100% coverage unit tests for retryOperation (MEN-39)#136
mento-val wants to merge 3 commits intomainfrom
qa/men-39-retry-operation-tests

Conversation

@mento-val
Copy link
Copy Markdown
Collaborator

Summary

  • Adds tests/unit/utils/retry.test.ts with 11 unit tests for retryOperation
  • Achieves 100% statement, branch, function, and line coverage on src/utils/retry.ts (up from 7.69% statement / 0% function)
  • Tests cover: first-try success, transient retry, exhausted retries, default/custom maxAttempts, maxAttempts=1 edge cases, exponential backoff timing (via fake timers), last-error message propagation, typed return value

Test plan

  • npm test -- --testPathPattern=tests/unit/utils/retry → 11/11 pass
  • Coverage for retry.ts: 100% stmts / 100% branches / 100% funcs / 100% lines
  • No regressions in existing test suite

Closes MEN-39

🤖 Generated with Claude Code

mento-val and others added 3 commits March 12, 2026 02:00
Added 93 new unit tests across two new test files:

- `BorrowService.extended.test.ts`: covers all 28 previously untested
  public methods (transaction building, approvals, read operations) with
  happy-path, validation-error, and edge-case scenarios. Uses a
  configurable mock client pattern to keep tests isolated.

- `borrowValidation.test.ts`: covers the 8 pure validation helpers
  (requireDebtTokenSymbol, parseTroveId, formatTroveId,
  requireNonNegativeInteger, requireNonNegativeBigInt,
  requirePositiveBigInt, requireUint128, ceilSqrt).

Coverage delta for services/borrow:
  Statements: 24.39% → 88.81% (BorrowService.ts: 100%)
  Branches:   15.06% → 74.32% (BorrowService.ts: 100%)
  Functions:  24.41% → 96.51% (BorrowService.ts: 100%)

Closes MEN-31.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- borrowMath.ts: add tests for getLtv, calculateMaxDebt, getLoanDetails
  (all branches including null inputs, underwater/liquidatable/at-risk/healthy
  statuses, zero collateral, negative collateral)
  → statements 72% → 98.4%, branches 24.5% → 98.1%

- TradingService.ts: add 10 tests for getPoolTradabilityStatus()
  covering circuit breaker OK/tripped (bitmask), limits OK/exhausted,
  combined failures, correct arg forwarding, multi-limit array
  → branches 0% → 100%

Closes MEN-31 (borrow coverage ≥60%), MEN-33 (getPoolTradabilityStatus ≥80% branch)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers success on first try, retry on transient failure, exhausted retries,
custom maxAttempts, edge cases (maxAttempts=1), exponential backoff timing,
and last-error message propagation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mento-val
Copy link
Copy Markdown
Collaborator Author

Closing this PR as part of a workflow change. Going forward, all PRs must be submitted through the fork-based review process: branches are pushed to mento-val's personal forks, reviewed by the Engineering Manager, and then the EM opens the upstream PR. This work is valid and will be re-submitted through the proper workflow once Val's fork remotes are configured. See Paperclip issue MEN-61 for context.

@mento-val mento-val closed this Mar 16, 2026
@bayological bayological deleted the qa/men-39-retry-operation-tests branch March 23, 2026 11:40
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.

1 participant