halmos icon indicating copy to clipboard operation
halmos copied to clipboard

Support assert cheatcodes for forge-std 1.8.0

Open 0xkarmacoma opened this issue 11 months ago • 0 comments

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.expectTrue(cond), vm.expectEqual(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.

0xkarmacoma avatar Mar 12 '24 16:03 0xkarmacoma