Migrate test suite from Hardhat to Foundry#2848
Open
clement-ux wants to merge 128 commits intomasterfrom
Open
Conversation
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>
…rnovaAMOStrategy - 18 unit test files (80 tests): constructor, deposit, withdraw, rebalance, fuzz - 7 fork test files (72 tests): fresh pool/gauge via factory authorization, front-running, insolvency - 6 smoke test files (19 tests): deployed contract validation via Resolver - Infrastructure: add Supernova addresses to Addresses.sol, strategy to Base.t.sol, proxy to deployments-1.json
…deployment setup - Add HyperEVM RPC endpoint to foundry.toml and fork helper in BaseFork.t.sol - Add HyperEVM chain routing (ID 999) to DeployManager and Base.s.sol - Create example deploy script in scripts/deploy/hyperevm/ - Create deployments-999.json with CrossChainRemoteStrategy address - Add HyperEVM smoke tests (ViewFunctions, BalanceUpdate, Deposit, Withdraw, RelayValidation) - Add fork-tests-hyperevm and smoke-tests-hyperevm CI jobs in foundry.yml - Rename CrossChainRemoteStrategy smoke tests to CrossChainRemoteStrategyBase
- Cache forge build artifacts (out/, cache/) to avoid recompiling 1007 files each job - Remove `needs: build` gate so test jobs start immediately in parallel - Split Fork Tests (Mainnet) into 3 matrix chunks for parallel execution - Skip foundry-setup entirely when no tests discovered for a chain
…Strategy - Unit tests (31): deposit, withdraw, withdrawAll override, maxWithdraw, view functions, and fuzz tests with limited liquidity simulation - Fork tests (20): fresh deploy against real Morpho V2 vault on mainnet fork with mocked share guard for whitelist bypass - Smoke tests (14): deployment health checks via DeployManager/Resolver - Add MockMorphoV2Vault and MockMorphoV2Adapter for unit test isolation - Register MORPHO_OUSD_V2_STRATEGY_PROXY in deployments-1.json
…alls - Commit pre-generated beacon proof fixture for slot 12235962 (20KB JSON) - Read fixture via vm.readFile() with FFI fallback for custom slots - Narrow forge build cache to exclude 273MB beacon SSZ state files - Reduce Mainnet fork chunks from 3 to 2 now that BeaconProofs is instant
…olidationController - Fork tests extend BaseFork with fresh OETH+OETHVault deployment - Strategy proxies upgraded to new impls pointing at fresh vault - Unit tests cover request/fail/confirm consolidation and operations - Smoke tests validate deployed configuration and forwarding - Add missing addresses to Addresses.sol (FeeAccumulators, BeaconProofs)
…s and fix HyperEVM smoke tests - Move fork/smoke tests into chain-specific subdirs (mainnet/, base/, sonic/, hyperevm/) - Update CI workflow to use `find` with chain-specific paths instead of `grep -rl` - Fix HyperEVM smoke tests: mock CCTP MessageTransmitter and TokenMessenger to avoid arithmetic overflow from real on-chain CCTP contracts - Run forge fmt on all test/script files to fix formatting
- Add Makefile with targets for build, test, deploy, coverage, and gas - Multi-chain support (mainnet, base, sonic, hyperevm) for test and deploy - Reorganize dev.env with consistent sections and annotations
The fork test was failing because the on-chain SSV validator state had changed, causing IncorrectValidatorStateWithData to revert before reaching the existing try-catch on removeSsvValidator. Both SSV calls are now wrapped since the test validates access control, not SSV state.
Wrap exitSsvValidator calls in try-catch to handle IncorrectValidatorStateWithData from the SSV Network when validators have already been exited on-chain. Falls back to vm.store where the test needs the EXITING state for subsequent assertions.
…ilation Base.t.sol imported ~60 contracts and was inherited by ~99 Shared.t.sol files. Any change to it invalidated the entire Foundry cache, triggering a full recompile. Strip Base.t.sol to only actors, constants, IERC20 external tokens, fork IDs, and setUp(). Move typed contract/proxy/mock variable declarations into each Shared.t.sol that actually uses them. Also add a [profile.test] section to foundry.toml with optimizer disabled and dynamic_test_linking enabled for faster test-only compilation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Verify deployment health for all four vault contracts via DeployManager/Resolver: - ViewFunctions: governor, strategist, default strategy, vault buffer, claim delay, pause states - Mint: totalValue increase, asset debit, vault receives asset - Rebase: succeeds, increases supply, previewYield correctness - Allocate: depositToStrategy, withdrawFromStrategy, totalValue preservation - WithdrawalQueue: metadata updates, multi-claim, liquidity management, request storage
Standalone Node.js script that compares storage layouts between git refs using forge inspect. Reviewers can run it during PR review to verify upgrades won't cause storage slot conflicts.
- Add --json flag to forge inspect and strip tracing logs from stdout - Install soldeer dependencies before building in worktrees - Make forge build non-fatal (partial builds can still inspect some contracts) - Handle the "carve from gap" upgrade pattern: new variables replacing the start of a __gap array are valid if the gap shrinks by the exact number of slots used
…hecker - Use install-deps.sh instead of forge soldeer install (handles npm tgz packages) - Run forge clean before building to avoid stale cache issues - Add extra_output_files = ["storageLayout"] to foundry.toml
Only compiles the target contract and its dependencies, not the entire repo. Reduces runtime from ~3min to ~10s per contract check.
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
Migrates the project's test suite from Hardhat to Foundry, introducing a comprehensive Foundry-based testing and deployment infrastructure. This is a large foundational PR that adds ~69,000 lines across 769 files, covering unit tests, fork tests, smoke tests, deployment tooling, CI, and AI-assisted development skills.
Foundry Test Suite (712 new test files, ~61,000 lines)
Unit tests covering 12 contract areas with high branch coverage:
Fork tests across 3 chains (Mainnet, Base, Sonic):
Smoke tests across 4 chains (Mainnet, Base, Sonic, HyperEVM):
Deployment Infrastructure
build/deployments-{1,146,8453,999}.jsonmapping contract names to addressesCI/CD (
foundry.ymlworkflow)defi.ymlworkflowTooling & DX
.env.example: Documents all required/optional environment variablesunit-test,fork-test,smoke-test,commit— codified conventions for generating tests that follow project patternsCleanup
MockRebornMintercontractdefi.ymlCI workflowTest plan
make test— run all Foundry unit testsmake test-fork-mainnet— run mainnet fork testsmake test-fork-base— run Base fork testsmake test-fork-sonic— run Sonic fork testsmake test-smoke-mainnet— run mainnet smoke testsmake coverage— verify coverage meets thresholdspnpm teststill passes)