diff --git a/testdata/cheats/ExpectRevert.t.sol b/testdata/cheats/ExpectRevert.t.sol index 00200477bf74..8e67c4ad2f91 100644 --- a/testdata/cheats/ExpectRevert.t.sol +++ b/testdata/cheats/ExpectRevert.t.sol @@ -8,7 +8,7 @@ contract Reverter { error CustomError(); function revertWithMessage(string memory message) public pure { - require(false, message); + revert(message); } function doNotRevert() public pure {} @@ -27,7 +27,7 @@ contract Reverter { function callThenRevert(Dummy dummy, string memory message) public pure { dummy.callMe(); - require(false, message); + revert(message); } function revertWithoutReason() public pure { @@ -37,7 +37,7 @@ contract Reverter { contract ConstructorReverter { constructor(string memory message) { - require(false, message); + revert(message); } } @@ -63,7 +63,7 @@ contract Dummy { } function largeReturnType() public pure returns (LargeDummyStruct memory) { - require(false, "reverted with large return type"); + revert("reverted with large return type"); } } @@ -80,6 +80,12 @@ contract ExpectRevertTest is DSTest { reverter.revertWithMessage("revert"); } + function testFailExpectRevertWrongString() public { + Reverter reverter = new Reverter(); + vm.expectRevert("my not so cool error"); + reverter.revertWithMessage("my cool error"); + } + function testFailRevertNotOnImmediateNextCall() public { Reverter reverter = new Reverter(); // expectRevert should only work for the next call. However,