test(utils): add 100% coverage unit tests for retryOperation (MEN-39)#136
Closed
test(utils): add 100% coverage unit tests for retryOperation (MEN-39)#136
Conversation
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>
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tests/unit/utils/retry.test.tswith 11 unit tests forretryOperationsrc/utils/retry.ts(up from 7.69% statement / 0% function)maxAttempts,maxAttempts=1edge cases, exponential backoff timing (via fake timers), last-error message propagation, typed return valueTest plan
npm test -- --testPathPattern=tests/unit/utils/retry→ 11/11 passretry.ts: 100% stmts / 100% branches / 100% funcs / 100% linesCloses MEN-39
🤖 Generated with Claude Code