Documentation ¶
Overview ¶
Package revert provides means for testing Ethereum reverted execution.
Index ¶
Constants ¶
const ( AlreadyInitialized = Checker("Initializable: contract is already initialized") OnlyOwner = Checker("Ownable: caller is not the owner") Paused = Checker("Pausable: paused") Reentrant = Checker("ReentrancyGuard: reentrant call") )
Checkers for OpenZeppelin modifiers.
const ( ERC721ApproveOrOwner = Checker("ERC721ACommon: Not approved nor owner") InvalidSignature = Checker("SignatureChecker: Invalid signature") NotStarted = Checker("LinearDutchAuction: Not started") SoldOut = Checker("Seller: Sold out") )
Checkers for ethier libraries and contracts.
const ( WETHWithdraw = Checker("WETH9Test: insufficient balance to withdraw") WETHTransfer = Checker("WETH9Test: insufficient balance to transfer") WETHAllowance = Checker("WETH9Test: insufficient allowance") )
Checkers for wETH test double. Use the wethtest package to deploy a modified wETH contract that includes these revert messages.
const Any = Checker("execution reverted")
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker string
A Checker checks that a transaction reverts with the specified string. The empty string is valid and only checks that a transaction reverted, but is agnostic to the message. Therefore the empty string IS NOT equivalent to a nil error.
func MissingRole ¶ added in v0.50.0
MissingRole returns a Checker that checks that a transaction reverts because the account requires but does not have the specified role.
func MissingRoleByName ¶ added in v0.50.0
MissingRoleByName returns a Checker that checks that a transaction reverts because the account requires but does not have the specified role name.
func (Checker) Diff ¶
Diff returns a message describing the difference between err and the Checker string, using substring matching. The empty-string Checker is treated as DefaultChecker.
The first argument to Diff is ignored but is present to allow transaction functions to be used directly as input, without assigning to intermediate variables. For example:
if diff := ethtest.OnlyOwner.Diff(contract.Foo(…)); diff != "" { t.Errorf("contract.Foo() %s", diff) }