Skip to content

Migrate test suite from Hardhat to Foundry#2848

Merged
clement-ux merged 162 commits into
masterfrom
clement/foundry-migration
Jul 23, 2026
Merged

Migrate test suite from Hardhat to Foundry#2848
clement-ux merged 162 commits into
masterfrom
clement/foundry-migration

Conversation

@clement-ux

@clement-ux clement-ux commented Mar 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

Migrates the smart contract test and deployment validation workflow from Hardhat to Foundry.

Also adds a fresh OUSD core deployment and hardens Foundry governance simulation and transaction broadcasting for Prague.

Changes

  • Adds Foundry unit, fork, and smoke tests.
  • Adds DeployManager and Resolver to test deployed contracts with pending governance applied.
  • Adds a fresh OUSD deployment script for the token, Vault, Wrapped OUSD, and VaultValueChecker.
  • Uses the Guardian multisig to propose and vote during mainnet governance simulations, since the Timelock has no delegated xOGN voting power.
  • Avoids Foundry's EIP-2935 block-history backfill during artificial governance block jumps by temporarily using Cancun execution semantics around vm.roll, then restoring the active EVM version.
  • Disables call isolation for real deployments with --no-isolate, ensuring nonces remain sequential when contract creations and calls are interleaved.
  • Ignores local Foundry broadcast artifacts.
  • Adds Foundry CI, Makefile targets, environment helpers, and test-generation skills.
  • Removes obsolete Hardhat, Echidna, oracle, and documentation files.

Foundry deployment notes

  • On Prague, the current Foundry nightly backfills the EIP-2935 history contract for every block skipped by vm.roll. Large governance jumps therefore trigger thousands of RPC block-hash and storage reads. Governance simulation temporarily switches only the roll cheatcode to Cancun and immediately restores Prague; the skipped blocks' synthetic EIP-2935 history is intentionally not populated.
  • Foundry isolation produced duplicate broadcast nonces when deployment calls and contract creations were interleaved. Real deployment commands use --no-isolate so each captured transaction increments the deployer nonce before the next address is calculated.

Test plan

  • make test
  • Fork tests
  • make test-smoke
  • Foundry CI
  • forge build scripts/deploy/
  • make simulate
  • Mainnet test deployment with governance calldata generation

clement-ux and others added 30 commits March 2, 2026 09:52
Set up forge compilation for all 302 Solidity files alongside existing
Hardhat config. Add foundry.toml with Soldeer deps (forge-std, OZ 4.4.2,
Chainlink CCIP, LayerZero v2, solidity-bytes-utils) and transitive
remappings for LZ dependency chain. Replace hardhat/console.sol import
with forge-std/console2.sol in MockRebornMinter.
Add MockStrategy and MockNonRebasing state variables and imports
to the shared Base contract so they are available to all test suites.
Shared.sol deploys OUSD + OUSDVault behind proxies, configures the
vault with withdrawal delay, rebase rate max, and drip duration,
then funds matt and josh with 100 OUSD each.

Mint.t.sol covers mint, deprecated mint overload, mintForStrategy,
burnForStrategy, and auto-allocate on mint (13 tests).
Cover governor(), isGovernor(), two-step transferGovernance +
claimGovernance flow, and access control reverts (9 tests).
Cover totalValue, checkBalance, getAssetCount, getAllAssets,
getStrategyCount, getAllStrategies, isSupportedAsset, and the
deprecated oUSD() accessor (18 tests).
Cover all VaultAdmin setters, pause functions, strategy management,
and token rescue. Includes revert paths for unauthorized callers,
invalid values, and edge cases like "Asset not supported by Strategy",
"Strategy has funds", and "Parameter length mismatch" (98 tests).
Cover rebase pausing, yield distribution to rebasing accounts,
non-rebasing exclusion, trustee fee accrual, previewYield,
drip duration smoothing, _nextYield early-return branches, and
the defensive fee >= yield check (19 tests).
Cover allocate to default strategy, vault buffer, withdrawal queue
reserves, depositToStrategy, withdrawFromStrategy,
withdrawAllFromStrategy, withdrawAllFromStrategies, capital-paused
revert, and early return when no asset available (23 tests).
Cover requestWithdrawal, claimWithdrawal, claimWithdrawals,
addWithdrawalQueueLiquidity, strategy-queue interactions,
mint-covers-outstanding scenarios, full drain edge cases,
insolvency and slash scenarios, solvency at 3%/10%
maxSupplyDiff, rebase-on-redeem, and capital-paused claims
(55 tests).
Add test directory, solmate dependency, and remappings to
foundry.toml. Add .gitkeep placeholders for the test directory
structure. Add lcov.info to .gitignore.
Captures the established test conventions (directory layout, inheritance
chain, naming patterns, helper idioms, fuzz config) so future contract
test suites follow the same structure as OUSDVault.
Add fuzz tests for mint, rebase, and withdraw covering key properties
(scaling, round-trip recovery, yield distribution, queue invariants).
Configure foundry.toml with 1024 runs and deterministic seed.
…to 96%

- Add Burn.t.sol and Initialize.t.sol for previously untested functions
- Add missing revert tests to Mint, TransferFrom, Transfer, YieldDelegation
- Fix truncated assertion in Mint.t.sol
- Update unit-test skill to enforce one file per function rule
Enforce minimum coverage thresholds: 100% functions, 90% branches/lines/statements.
Includes iterative improvement workflow and requires explanation for uncovered paths.
…onic, WrappedOusd)

Add Foundry unit tests for remaining wrapped token variants and declare
their state variables in Base.sol for shared test infrastructure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…r contracts

Add comprehensive unit tests for OETHZapper, OETHBaseZapper, OSonicZapper,
and WOETHCCIPZapper. Tests cover all public functions, revert conditions,
event emissions, and edge cases. Uses vm.mockCall for CCIP router and
vm.etch for hardcoded addresses (wS, Base WETH).

35 tests across 9 test suites — 100% line/statement/branch/function coverage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…% coverage

Add 120 tests across 22 files covering CurvePoolBooster, CurvePoolBoosterPlain,
and CurvePoolBoosterFactory. Includes concrete tests for all public/external
functions and fuzz tests for fee handling and salt encoding.

Also adds shared test infrastructure: Base.sol pool booster state vars,
MockCreateX for deterministic CREATE2 testing, and naming convention rules.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add unit tests for PoolBoosterMerkl and PoolBoosterFactoryMerkl covering
constructor, bribe, isValidSignature, getNextPeriodStartTime, factory
create/compute, and setMerklDistributor. Includes fuzz test for period timing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add unit tests for PoolBoosterSwapxSingle, PoolBoosterSwapxDouble, and their
factories. Covers constructor validation, bribe mechanics, split calculations,
factory create/compute, and abstract factory functions (bribeAll, removePoolBooster).
Includes fuzz test for double bribe split amounts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add unit tests for PoolBoosterMetropolis and PoolBoosterFactoryMetropolis
covering constructor, bribe mechanics with rewarder/voter mocking, and
factory create/compute functions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…overage

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Ensures forge excludes test helper files from coverage reports.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…h 100% coverage

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
clement-ux and others added 21 commits April 17, 2026 10:50
Resolves:
- .github/workflows/defi.yml: keep deleted (replaced by foundry.yml)
- contracts/dev.env: keep Foundry-oriented structure, preserve master's
  Automaton/nonce-queue vars and the still-live Hardhat vars, and document
  both the Foundry (FORK_BLOCK_NUMBER_*) and Hardhat (BLOCK_NUMBER) fork-block
  conventions.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KQTR6rq3bhucMHXFoNXxJT
…s for WOETHPlume and WOSonic

- Deleted unit tests for WOETHPlume: Deposit, ViewFunctions, and Shared utilities.
- Deleted unit tests for WOSonic: Deposit, ViewFunctions, and Shared utilities.
- Removed unused artifacts and references related to OSonic and WOETH in Proxies, Tokens, Vaults, Strategies, and Zappers.
- Cleaned up PoolBoosters artifacts by removing obsolete factory references.
- Deleted OSonicOracleRouter.sol and OracleRouter.sol as they are no longer needed.
- Removed related README.md files and SVG diagrams for OETH and Oracle routers.
- Updated generate.sh script to exclude Oracle-related UML generation.
- Cleaned up PlantUML files by removing references to obsolete Oracle components.
…vailable and add isModuleAvailable flag in shared test
* migrate all of the talos actions to viem and away from hardhat

* changing in place ethers references to remove hardhat

* remove unneeded files
…time

- getBlock/getDiffBlocks resolve the provider via tasks/lib/network for the
  standalone action CLI, with an hre fallback for legacy hardhat dev tasks
- lazy-require @nomicfoundation/hardhat-network-helpers (mine) so importing
  block.js no longer loads hardhat; only advanceBlocks (test/dev) needs it
- completes the Talos hardhat removal: block.js was the last module pulling
  hardhat onto the standalone action runtime path (tasks/lib/network merged
  via #2943)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* add test report

* update test report

* fix error message

* add the easy tests

* update decisions

* test: cover OUSD delegation accounting and strategy config

* test(origin): strengthen curve amo front-running coverage

* feat(deploy): support Base and HyperEVM timelocks

* docs: record foundry migration batch two

* chore: update tests and defender action bundles

* chore: ignore generated defender bundles

* chore: match CI Forge formatting

* chore: format auto withdrawal task

* docs: record skip decisions in foundry migration open questions

Mark #5 (Algebra/Hydrex AMO), #7 (RebalancerModule), #10 (legacy OUSD
migration-state), #11 (whale withdrawAllFromStrategies) and #13
(WOETH-upgrade/EigenLayer/EIP-7702) as skipped; keeps Batch 2's #9 result.
Open: #3, #4, #12.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test(ssv): cover 21 validators with real beacon proofs

* docs(gap): mark 21-validator SSV real-proof scenarios as closed

Closed by 200e9cd (TwentyOneValidators.t.sol): the three multi-validator
real-Beacon-proof scenarios now covered. strat-compounding-ssv 75->78 covered,
26->23 missing; Total 1071->1074 / 434->431.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Clément <clemmoller@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
sparrowDom
sparrowDom previously approved these changes Jul 22, 2026

@sparrowDom sparrowDom left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of comments inline otherwise LGTM

Comment thread contracts/build/deployments-1.json
Comment thread contracts/scripts/deploy/helpers/GovHelper.sol Outdated
@clement-ux
clement-ux merged commit f914918 into master Jul 23, 2026
11 checks passed
@clement-ux
clement-ux deleted the clement/foundry-migration branch July 23, 2026 07:47
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.

3 participants