Created
April 5, 2022 18:16
-
-
Save ecmendenhall/abd66ddbbb797f286e0bcd45317b22b5 to your computer and use it in GitHub Desktop.
Fuzz test without error message
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: Apache-2.0 | |
pragma solidity 0.8.10; | |
import "ds-test/test.sol"; | |
contract ExampleTest is DSTest { | |
function test_fuzz_reverts_with_message(uint256 n) public { | |
revert("message"); | |
assertEq(n, 1); | |
} | |
function test_fuzz_reverts_without_message(uint256 n) public { | |
revert(); | |
assertEq(n, 1); | |
} | |
function test_unit_reverts_with_message() public { | |
revert("message"); | |
uint256 two = 2; | |
assertEq(two, 1); | |
} | |
function test_unit_reverts_without_message() public { | |
revert(); | |
uint256 two = 2; | |
assertEq(two, 1); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Running 4 tests for src/test/Example.t.sol:ExampleTest | |
[FAIL. Reason: message. Counterexample: calldata=0x13f37b520000000000000000000000000000000000000000000000000000000000000000, args=[0]] test_fuzz_reverts_with_message(uint256) (runs: 0, μ: 0, ~: 0) | |
[FAIL. Counterexample: calldata=0x3d4a65530000000000000000000000000000000000000000000000000000000000000000, args=[0]] test_fuzz_reverts_without_message(uint256) (runs: 0, μ: 0, ~: 0) | |
[FAIL. Reason: message] test_unit_reverts_with_message() (gas: 290) | |
[FAIL. Reason: Revert] test_unit_reverts_without_message() (gas: 151) | |
Test result: FAILED. 0 passed; 4 failed; finished in 173.83µs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment