revert

package
v0.55.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package revert provides means for testing Ethereum reverted execution.

Index

Constants

View Source
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.

View Source
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.

View Source
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.

View Source
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

func MissingRole(account common.Address, role [32]byte) Checker

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

func MissingRoleByName(account common.Address, name string) Checker

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

func (c Checker) Diff(_ interface{}, err error) string

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)
 }

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL