Skip to content

test(utils): add 100% coverage unit tests for chainConfig.ts (MEN-40)#137

Closed
mento-val wants to merge 5 commits intomainfrom
qa/men-40-chainconfig-tests
Closed

test(utils): add 100% coverage unit tests for chainConfig.ts (MEN-40)#137
mento-val wants to merge 5 commits intomainfrom
qa/men-40-chainconfig-tests

Conversation

@mento-val
Copy link
Copy Markdown
Collaborator

Summary

  • Adds 12 unit tests for getDefaultRpcUrl() and getChainConfig() in src/utils/chainConfig.ts
  • Covers happy paths for Celo mainnet and Celo Sepolia, plus error handling for unknown/invalid chain IDs
  • Achieves 100% statement, branch, function, and line coverage

Test plan

  • getDefaultRpcUrl returns correct RPC URLs for CELO and CELO_SEPOLIA
  • getDefaultRpcUrl throws for unsupported chain IDs
  • getChainConfig returns correct Celo mainnet chain config
  • getChainConfig returns correct Celo Sepolia config (id, name, testnet flag)
  • getChainConfig throws for unsupported chain IDs
  • Celo Sepolia default RPC URL is consistent between both functions
  • All 12 tests pass under npm test
  • 100% coverage on chainConfig.ts

Closes MEN-40

🤖 Generated with Claude Code

mento-val and others added 5 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>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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-40-chainconfig-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