Skip to content

Improved support for foundry tests#1499

Open
gustavo-grieco wants to merge 19 commits intomasterfrom
dev-improve-foundry-support
Open

Improved support for foundry tests#1499
gustavo-grieco wants to merge 19 commits intomasterfrom
dev-improve-foundry-support

Conversation

@gustavo-grieco
Copy link
Collaborator

Foundry tests should be able to be used, as much as possible. In particular, we could re-use all the test infrastructure, for stateless tests. We want to eventually reach some decent level of compatibility.

@gustavo-grieco
Copy link
Collaborator Author

@BowTiedRadone do you want to own this PR? We need to add some test integration with Foundry so we can verify we are catching correctly the failures (at least, for stateless tests)

@BowTiedRadone
Copy link
Contributor

@gustavo-grieco Sure! Thanks.

BowTiedRadone and others added 16 commits January 13, 2026 13:45
* 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 <2642849+elopez@users.noreply.github.com>
* 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`
Comment on lines +41 to +49
{-Failure _ _ (Revert msg) -> case msg of
ConcreteBuf b ->
-- NOTE: assertTrue/assertFalse does not have the double colon after "assertion failed"
let assertFail = (selector "Error(string)" `BS.isPrefixOf` b) &&
("assertion failed" `BS.isPrefixOf` BS.drop txtOffset b)
in if assertFail || b == panicMsg 0x01 then PBool False
else PBool True
_ -> error "Non-concrete revert message in assertion check"
-}
Copy link
Member

Choose a reason for hiding this comment

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

is this needed? if not, can you remove the commented out code?

Comment on lines +291 to +292
liftIO $ print symTxs
liftIO $ print partials
Copy link
Member

Choose a reason for hiding this comment

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

is this used? It looks like it might be debug prints

filterMethodsWithArgs ms =
case NE.filter (\(n, xs) -> T.isPrefixOf "invariant_" n || not (null xs)) ms of
[] -> error "No dapptest tests found"
case NE.filter (\(n, xs) -> T.isPrefixOf "test" n || (T.isPrefixOf "invariant_" n || not (null xs))) ms of
Copy link
Member

Choose a reason for hiding this comment

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

is this a foundry convention?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

isDapptestMode _ = False
isFoundryMode :: TestMode -> Bool
isFoundryMode "foundry" = True
isFoundryMode _ = False
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
isFoundryMode _ = False
isFoundryMode _ = False

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