revert

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package revert provides means for testing Ethereum reverted execution.

Index

Constants

View Source
const (
	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("ERC721Common: Not approved nor owner")
	NotStarted           = Checker("LinearDutchAuction: Not started")
	SoldOut              = Checker("Seller: Sold out")
)

Checkers for ethier modifiers.

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 (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