Skip to content

Commit

Permalink
add symbolic revert test
Browse files Browse the repository at this point in the history
  • Loading branch information
karmacoma-eth committed Aug 21, 2024
1 parent af3df48 commit afd5c11
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/expected/all.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@
"num_paths": null,
"time": null,
"num_bounded_loops": null
},
{
"name": "check_symbolic_revert(uint256)",
"exitcode": 0,
"num_models": 0,
"models": null,
"num_paths": null,
"time": null,
"num_bounded_loops": null
}
],
"test/Block.t.sol:BlockCheatCodeTest": [
Expand Down
12 changes: 12 additions & 0 deletions tests/regression/test/AssertTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,16 @@ contract AssertTest is Test {
function check_fail_propagated() public {
address(c).call(abi.encodeWithSelector(C.bar.selector, bytes(""))); // fail
}

function check_symbolic_revert(uint256 x) public {
// reverts with Concat(0x4e487b71, p_x_uint256())
// halmos only considers reverts with explicit revert codes so we expect a PASS here
// this is really to make sure we handle symbolic reverts gracefully
if (x > 0) {
bytes memory data = abi.encodeWithSignature("Panic(uint256)", x);
assembly {
revert(add(data, 0x20), mload(data))
}
}
}
}

0 comments on commit afd5c11

Please sign in to comment.