Skip to content

test(lend): deployed-sanity flow suite for the dev deployment#200

Open
nikkaroraa wants to merge 2 commits into
feat/lendfrom
test/lend-dev-sanity-suite
Open

test(lend): deployed-sanity flow suite for the dev deployment#200
nikkaroraa wants to merge 2 commits into
feat/lendfrom
test/lend-dev-sanity-suite

Conversation

@nikkaroraa

@nikkaroraa nikkaroraa commented Jul 18, 2026

Copy link
Copy Markdown

What

A fork-based sanity suite (test/deployed-sanity/LendDev*) that drives one live operation through every deployed Lend surface against the live Optimism dev contracts, plus the future retire pass as a real script.

  • LendDevTestBase — shared fork base: address binding from the dev manifests, dev-admin impersonation, signing helpers, optional LEND_DEV_FORK_BLOCK pin to reuse the fork cache.
  • LendDevFlows (19) — engine routing + legacy paths, opt-out lifecycle (pending window, opt-back-in, matured unwind, open-debt guard, migrate-while-opted-out), spend with cashback, mixed-engine top-up batch, hook no-op on a gateway safe.
  • LendDevModules (8) — one sandwich per deployed module (liquid, liquidReferrer, stake, frax, midas, beHYPE, openOcean, liquifier), with external protocols etched at their real addresses; safe/module/gateway/Aave legs stay real.
  • LendDevWithdrawals (5) — reservation vs sweep and vs canSpend, cancel frees the reservation, module-requested withdrawals, and a rehearsal of the retire pass showing why a pending withdrawal to an old module strands.
  • scripts/lend/RetireOldModulesDev.s.sol — the future retire pass, gated behind a PENDING_WITHDRAWALS_CHECKED=true preflight.

Why

Post-deploy confidence that the live dev wiring actually works end to end. It already caught a real gap: the deployed LendGateway was not registered as a default module, so every gateway supply was silently left loose and migrations/credit spends/signed borrows reverted. That fix is re-applied here in the deploy/verify scripts (it had been silently dropped in an earlier merge).

How tested

```
source .env && forge test --match-path "test/deployed-sanity/LendDev*" --threads 2 -vv
```

All 32 green against live Optimism dev (pin LEND_DEV_FORK_BLOCK to reuse the fork cache; parallel suites 429 public RPCs). Run manually post-deploy — added as a checklist step in the Notion runbook, not wired into CI.

Note for review

Look closely at the DeployCashLendDev / VerifyCashLendDev hunk — that default-module registration has vanished in a merge once already. External-protocol stubs in LendDevModules are test-only and carry the expected erc20-unchecked-transfer lint warnings.


Note

Low Risk
Changes are dev-only scripts and fork tests plus a one-time data-provider config in deploy; no production contract logic changes, though the default-module gap it fixes was operationally critical for gateway supplies.

Overview
Adds a manual fork suite (test/deployed-sanity/LendDev*) that exercises live Optimism dev Cash/Lend wiring end-to-end: legacy vs gateway routing, migration, onboarding, spends/borrows, opt-out, per-module Aave sandwiches (external protocols stubbed via vm.etch), withdrawal reservation edges, and a retire-script rehearsal.

Deploy/verify fix: DeployCashLendDev now calls configureDefaultModules so LendGateway is a default module (needed for execTransactionFromModule / Aave position-manager self-approval); VerifyCashLendDev asserts that flag. The base patches the fork if live chain is still wrong so flow tests pass while test_deployedConfig_gatewayIsDefaultModule stays red until fixed on-chain.

Ops: New RetireOldModulesDev.s.sol revokes withdraw-requester and default/whitelist status for the seven pre-Lend modules, gated on PENDING_WITHDRAWALS_CHECKED=true after check-pending-withdrawals.sh.

Reviewed by Cursor Bugbot for commit 0bc02aa. Bugbot is set up for automated code reviews on this repo. Configure here.

…ripts

The gateway self-approves as each safe's Aave position manager through
execTransactionFromModule, which only a default module may call. Without
default-module status every gateway supply is silently left loose and every
migration, credit spend, and signed borrow reverts. The deploy script now
registers it and Verify asserts it. This fix was silently dropped in an earlier
merge and is being re-applied.
Fork-based sanity suite that drives one live operation through every deployed
Lend surface against the Optimism dev contracts: engine routing and lifecycle,
opt-out states, cashback and mixed-engine top-ups, a sandwich per module (with
external protocols etched at their real addresses), and withdrawal reservation
edges. Also adds RetireOldModulesDev, the future retire pass gated behind a
pending-withdrawal preflight; the withdrawals suite rehearses it on a fork to
show why the scan must run first.

Run: forge test --match-path "test/deployed-sanity/LendDev*" --threads 2 -vv
(pin LEND_DEV_FORK_BLOCK to reuse the fork cache).
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

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