Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support assert cheatcodes for forge-std 1.8.0 #256

Closed
karmacoma-eth opened this issue Mar 12, 2024 · 2 comments
Closed

Support assert cheatcodes for forge-std 1.8.0 #256

karmacoma-eth opened this issue Mar 12, 2024 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@karmacoma-eth
Copy link
Collaborator

karmacoma-eth commented Mar 12, 2024

Problem

The behavior of assertions in StdAssertions.sol in forge-std v1.8.0 is changing.

The old behavior is a "soft assert" in solidity, it logs a message and calls fail() to mark the test failed, but it otherwise continues.

The new behavior is to invoke "native" cheats like vm.assertTrue(cond), vm.assertEqual(left, right), etc. These new cheats cause the tests to exit early, which should make traces in failed tests easier to read. Eventually this should result in a nice performance boost too for tests with many asserts, but halmos doesn't support these cheats at the moment.

Solution

Implement these cheatcodes:
https://github.com/foundry-rs/forge-std/blob/master/src/Vm.sol#L781-L1209

In halmos:
https://github.com/a16z/halmos/blob/main/src/halmos/cheatcodes.py

We also need to adopt the reverting behavior to benefit from the early exits.

@karmacoma-eth karmacoma-eth added the enhancement New feature or request label Mar 12, 2024
@daejunpark daejunpark added good first issue Good for newcomers help wanted Extra attention is needed labels Mar 26, 2024
@EmperorOrokuSaki
Copy link
Contributor

I'm taking this

@karmacoma-eth
Copy link
Collaborator Author

implemented in #323

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants