Skip to content

Commit

Permalink
Document expectRevert() (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp authored Mar 22, 2022
1 parent 1a0c2c1 commit 6f408ee
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/reference/cheatcodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ interface CheatCodes {
function etch(address who, bytes calldata code) external;
// Sets an address' code
function expectRevert() external;
function expectRevert(bytes calldata) external;
function expectRevert(bytes4) external;
// Expects an error on next call
Expand Down Expand Up @@ -376,6 +377,24 @@ An alternative version of [`expectRevert`](#expectrevert) that only takes an err
cheats.expectRevert(MyContract.CustomError.selector)
```

##### Alternative Signature without error message

```solidity
function expectRevert() external;
```

If you need to test that a function reverts _without_ a message, you can do so with `expectRevert()`.

###### Example

```solidity
function testExpectRevertNoReason() public {
Reverter reverter = new Reverter();
cheats.expectRevert();
reverter.revertWithoutReason();
}
```

<br>

---
Expand Down

0 comments on commit 6f408ee

Please sign in to comment.