Skip to content

Fix bugs in Foundry test generation#1516

Merged
gustavo-grieco merged 8 commits intocrytic:dev-improve-foundry-supportfrom
BowTiedRadone:fix/foundry-test-gen-bugfixes
Jan 26, 2026
Merged

Fix bugs in Foundry test generation#1516
gustavo-grieco merged 8 commits intocrytic:dev-improve-foundry-supportfrom
BowTiedRadone:fix/foundry-test-gen-bugfixes

Conversation

@BowTiedRadone
Copy link
Copy Markdown
Contributor

This PR fixes two Foundry test generation bugs reported in #1465:

  1. Fallback functions: Generated invalid syntax Target.() -> now generates address(Target).call("")
  2. Null bytes in arguments: Generated invalid escape sequences like hex"<nul><nul><nul>" -> now generates proper hex like hex"000102"

Both fixes include tests that verify the generated code compiles with forge build.

@elopez
Copy link
Copy Markdown
Member

elopez commented Jan 14, 2026

I think the second bug might be the one we solved here: #1514
I merged the master branch on the other PR and tried to sort out the conflicts, but please recheck and remove the redundant test if not needed.

@BowTiedRadone
Copy link
Copy Markdown
Contributor Author

@elopez Thanks! Checked and it looks fine. I think the end-to-end null byte test brings value, because it is checking if the generated test actually compiles with forge. However, I'll leave the final decision up to @gustavo-grieco and you.

@gustavo-grieco gustavo-grieco merged commit e34cff3 into crytic:dev-improve-foundry-support Jan 26, 2026
1 check passed
@BowTiedRadone BowTiedRadone deleted the fix/foundry-test-gen-bugfixes branch January 27, 2026 23:58
gustavo-grieco added a commit that referenced this pull request Mar 13, 2026
* improved support for foundry tests

* Extend Foundry support testing (#1512)

* Fix lint failures

* ci: bump python version to 3.10, clone submodules

* some fixes when using foundry mode

* Update hevm to `542986dea3bec4f5898731ff48877a7a21811bf4`

* Fix bugs in Foundry test generation (#1516)

* Fix fallback function bug in Foundry test generation

* Fix null byte in argument bug in Foundry test generation

* Remove unnecessary config file

* Remove unused/redundant imports

* Disable Slither in Foundry test gen tests

* Conditionally run forge-std tests based on the solc version

* Reduce unnecessary test grouping and improve failed assertion messages

---------

Co-authored-by: Emilio López <[email protected]>

* Update hevm to `41e6d1304411749ea8c816d131991663b5dca67a`

* Fix linter and build errors (#1521)

* improve foundry stateful invariant testing

* fix

* Fix foundry test generation linter hints and tests (#1522)

* Foundry updates (#1525)

* Rename dapptest to foundry and support foundry assertX in assertion mode

* Rename basic foundry test contracts dir to `foundry-basic`

* Add testing modes to `README`

* fixes

* fixes

* Add support for Foundry assume (#1528)

* flake: sync hevm version with stack.yaml

* Clarify `optimization` test mode in `README` (#1529)

* IS_TEST fix

---------

Co-authored-by: Radu Bahmata <[email protected]>
Co-authored-by: Emilio López <[email protected]>
Co-authored-by: Emilio López <[email protected]>
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