Skip to content

Fix Foundry test generation contract name collision#1484

Merged
gustavo-grieco merged 3 commits intocrytic:masterfrom
BowTiedRadone:fix/foundry-test-gen
Dec 15, 2025
Merged

Fix Foundry test generation contract name collision#1484
gustavo-grieco merged 3 commits intocrytic:masterfrom
BowTiedRadone:fix/foundry-test-gen

Conversation

@BowTiedRadone
Copy link
Copy Markdown
Contributor

This PR changes generated Foundry tests contract name from "Test" to "FoundryTest" to avoid identifier collision with the forge-std/Test.sol base class. The previous output contract Test is Test caused a Solidity compilation error.

Part of #1465 report.

@gustavo-grieco
Copy link
Copy Markdown
Collaborator

This looks good, but I would like to have the test for this feature to actually call foundry with a minimal example and verify it compiles correctly. While it is a trivial to know that it works here, this test functionality will be useful for future PRs (there are a couple of foundry issues that also will need a unit test).

@BowTiedRadone BowTiedRadone force-pushed the fix/foundry-test-gen branch 3 times, most recently from 8b5f37f to afc3de0 Compare November 29, 2025 21:43
@BowTiedRadone
Copy link
Copy Markdown
Contributor Author

@gustavo-grieco Updated the test so it runs forge init. This required adding a Foundry installation step in CI.

@BowTiedRadone
Copy link
Copy Markdown
Contributor Author

@gustavo-grieco Anything left to be covered in this PR?

@gustavo-grieco
Copy link
Copy Markdown
Collaborator

I think this one looks good, but it will be merged after the release of 2.3 (which can be as close as next week). I'm very interested to develop this test code into a full test of the foundry unit-test capabilities (e.g. breaking an invariant, generating the foundry test and then run forge test to check that the test can be reproduced. Are you interested in keep expanding this in a future PR?

@BowTiedRadone
Copy link
Copy Markdown
Contributor Author

@gustavo-grieco Thanks for the update and looking forward to 2.3! 🚀

Are you interested in keep expanding this in a future PR?

Sure! Also, two more Foundry test generation fixes that I'm planning to resolve are left (#1465).

@gustavo-grieco gustavo-grieco merged commit 235fb75 into crytic:master Dec 15, 2025
16 of 20 checks passed
@BowTiedRadone BowTiedRadone deleted the fix/foundry-test-gen branch December 15, 2025 23:34
datradito pushed a commit to datradito/echidna-mcp that referenced this pull request Dec 29, 2025
* Fix Foundry test generation contract name collision

* Add actual forge compilation test in Foundry test generation suite

* Install foundry in CI
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