Skip to content

feat: add Foundry alongside Hardhat - #715

Merged
GitGuru7 merged 16 commits into
developfrom
feat/foundry-tests
Sep 29, 2026
Merged

GitGuru7 merged 16 commits into
developfrom
feat/foundry-tests

Conversation

@GitGuru7

@GitGuru7 GitGuru7 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds Foundry next to Hardhat for fuzz and invariant tests. Hardhat still owns the unit tests, deployments, coverage, the storage-layout check and the zkSync build. No existing test is changed.

Changes

  • foundry.toml, forge-std v1.16.2 as a submodule in lib/, one-line remappings.txt for editors
  • yarn test and yarn clean also run Foundry
  • CI: new Forge tests job on Foundry v1.5.1 with the ci profile (2000 fuzz runs, 1000 × 100 invariant)
  • Foundry writes to out/ and cache-foundry/, separate from Hardhat's artifacts/ and cache/
  • tests/foundry/README.md: layout, what belongs in which toolchain, the 0.5.16 boundary

Tests (tests/foundry)

These tests are added to verify the setup end to end against real contracts. They are a starting point, not full coverage.

Suite Checks
Comptroller/Diamond Calls route through the real diamond and its facets
Comptroller/Markets Listing, enter/exit, risk-parameter bounds (fuzz)
VToken/MintRedeem Mint and redeem amounts; a round trip never profits, a mint never lowers the exchange rate (fuzz)
VToken/Invariants Cash matches the token balance, the exchange rate never falls, the market stays solvent

Testing

13/13 passing on Foundry 1.3.5 and v1.5.1, both profiles.

@GitGuru7
GitGuru7 marked this pull request as ready for review September 28, 2026 06:21
@greptile-apps

greptile-apps Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 3/5

[Medium risk] Adds Foundry test framework alongside Hardhat.

The PR should not merge until the standard local test workflow is usable as documented and the exchange-rate invariant can detect a decrease.

Findings

  1. P1 Standard test setup fails ▶
  2. P1 Exchange rate check always passes ▶

Summary

The PR adds Foundry configuration, a pinned forge-std submodule, a dedicated CI job, and Comptroller and vToken fuzz/invariant suites alongside Hardhat.

  • The standard local test command now has prerequisites absent from the main installation instructions.
  • The exchange-rate invariant cannot detect a falling rate because its reference value is overwritten after each action.
  • The new risk-parameter test, handler, and counterexample guidance have narrower test-quality and documentation issues.

Reviews (1) · Last reviewed commit: "chore: drop redundant foundry config, fo..."

Comment thread package.json Outdated
Comment thread tests/foundry/VToken/VTokenBase.t.sol Outdated
@github-actions

Copy link
Copy Markdown

Code Coverage

Package Line Rate Branch Rate Health
contracts 100% 100% ✔
contracts.Admin 88% 41% ✔
contracts.BStock 100% 97% ✔
contracts.Comptroller 100% 90% ✔
contracts.Comptroller.Diamond 95% 66% ✔
contracts.Comptroller.Diamond.facets 88% 74% ✔
contracts.Comptroller.Diamond.interfaces 100% 100% ✔
contracts.Comptroller.Types 100% 100% ✔
contracts.Comptroller.legacy 100% 100% ✔
contracts.Comptroller.legacy.Diamond 0% 0% ❌
contracts.Comptroller.legacy.Diamond.facets 0% 0% ❌
contracts.Comptroller.legacy.Diamond.interfaces 100% 100% ✔
contracts.DelegateBorrowers 100% 89% ✔
contracts.FlashLoan.interfaces 100% 100% ✔
contracts.Governance 68% 45% ➖
contracts.InterestRateModels 74% 59% ➖
contracts.Lens 44% 47% ❌
contracts.Liquidator 83% 60% ✔
contracts.Oracle 100% 100% ✔
contracts.PegStability 88% 84% ✔
contracts.Swap 88% 58% ✔
contracts.Swap.interfaces 100% 100% ✔
contracts.Swap.lib 81% 55% ✔
contracts.Tokens 100% 100% ✔
contracts.Tokens.Prime 97% 81% ✔
contracts.Tokens.Prime.Interfaces 100% 100% ✔
contracts.Tokens.Prime.libs 90% 77% ✔
contracts.Tokens.VAI 82% 52% ✔
contracts.Tokens.VRT 20% 9% ❌
contracts.Tokens.VTokens 71% 53% ➖
contracts.Tokens.VTokens.legacy 0% 0% ❌
contracts.Tokens.VTokens.legacy.Utils 0% 0% ❌
contracts.Tokens.XVS 19% 8% ❌
contracts.Tokens.test 100% 100% ✔
contracts.Utils 52% 31% ➖
contracts.VAIVault 50% 45% ➖
contracts.VRTVault 49% 36% ❌
contracts.XVSVault 63% 50% ➖
contracts.external 100% 100% ✔
contracts.lib 89% 71% ✔
Summary 62% (4519 / 7315) 48% (1753 / 3646) ➖

@GitGuru7 GitGuru7 self-assigned this Sep 29, 2026
@GitGuru7
GitGuru7 merged commit c1a2bf9 into develop Sep 29, 2026
7 checks passed
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.

2 participants