Open
Description
hevm version
0.54.2 [no git revision present]
It seems that revert()
behaves like assume
, while revert("message")
behaves like assert
. This cause a big trouble when I'm using hevm, since I want all revert behaves like assume
.
Here is a demo to demonstrate the difference:
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.17;
import "forge-std/Test.sol";
contract RevertAssertDemoTest is Test {
function prove_func(uint256 revertControlInput) public {
if (revertControlInput == 0) {
revert();
}
assert(true);
}
}
rm -rf out/TestRevertAssert.sol && forge build --ast && hevm test --max-iterations 1000000000000000
[⠒] Compiling...
[⠰] Compiling 19 files with 0.8.17
[⠒] Solc 0.8.17 finished in 2.13s
Compiler run successful with warnings:
Warning (2018): Function state mutability can be restricted to pure
--> src/TestRevertAssert.sol:6:5:
|
6 | function prove_func(uint256 revertControlInput) public {
| ^ (Relevant source part starts here and spans across multiple lines).
Checking 1 function(s) in contract src/TestRevertAssert.sol:RevertAssertDemoTest
[RUNNING] prove_func(uint256)
[PASS] prove_func
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.17;
import "forge-std/Test.sol";
contract RevertAssertDemoTest is Test {
function prove_func(uint256 revertControlInput) public {
if (revertControlInput == 0) {
revert("some error message");
}
assert(true);
}
}
rm -rf out/TestRevertAssert.sol && forge build --ast && hevm test --max-iterations 1000000000000000
[⠒] Compiling...
[⠰] Compiling 19 files with 0.8.17
[⠒] Solc 0.8.17 finished in 2.20s
Compiler run successful with warnings:
Warning (2018): Function state mutability can be restricted to pure
--> src/TestRevertAssert.sol:6:5:
|
6 | function prove_func(uint256 revertControlInput) public {
| ^ (Relevant source part starts here and spans across multiple lines).
Checking 1 function(s) in contract src/TestRevertAssert.sol:RevertAssertDemoTest
[RUNNING] prove_func(uint256)
[FAIL] prove_func
Counterexample:
result: Revert: 0x08c379a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000012736f6d65206572726f72206d6573736167650000000000000000000000000000
calldata: prove_func(00000000000000000000000000000000000000000000000000000000000000000182dad8c17bd5e89e8043a08ada90a6d5efdee4425f85cb863109783e158ba4fba908a0e6fae6c6b51002)
Metadata
Metadata
Assignees
Labels
No labels