Skip to content

Withdraw reserves and approveThis refactoring#378

Open
VladyslavPerederWoof wants to merge 4 commits intofeat/service-patchfrom
test/withdraw-reserves-refactoring
Open

Withdraw reserves and approveThis refactoring#378
VladyslavPerederWoof wants to merge 4 commits intofeat/service-patchfrom
test/withdraw-reserves-refactoring

Conversation

@VladyslavPerederWoof
Copy link
Copy Markdown
Collaborator

@VladyslavPerederWoof VladyslavPerederWoof commented Apr 8, 2026

Summary

Rewrote withdrawReserves and approveThis tests from scratch. The old tests relied on banned patterns (setTotalsBasic, wait(), intermediate connection variables) and targeted base Comet.sol. New tests use real protocol interactions to build state and target CometWithExtendedAssetList per current conventions.

Merged the standalone approve-this-test.ts into withdraw-reserves-test.ts since both functions cover governor-controlled reserve and token management.

What changed

withdrawReserves scenarios:

  • Initial market state - zero reserves, zero-amount edge case, access control
  • Seeded reserves - direct token transfer, partial/full withdrawal, event checks
  • Organic reserves - real supply/borrow at 50% utilization, 1-year time advance, interest spread accumulation, partial and full drain
  • Phantom reserves at 100% utilization - positive getReserves() but zero physical balance, ERC-20 transfer failure, recovery after borrower repays
  • Multiple sequential withdrawals over separate time periods

approveThis scenarios:

  • Base token approval - governor grants allowance to manager, extraction via transferFrom, reserves impact, full drain bypassing InsufficientReserves guard
  • Collateral token approval - post-absorption rescue pattern, reset-and-reapprove flow for USDT-style tokens
  • Arbitrary token rescue - recovering unsupported tokens accidentally sent to the protocol

test/approve-this-test.ts - deleted

Old tests merged into the approveThis section of withdraw-reserves-test.ts.

@VladyslavPerederWoof VladyslavPerederWoof added the Tests Tests refactoring label Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Tests Tests refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant