Documentation ¶
Index ¶
- Constants
- Variables
- func AfterWaitTimeout(t *testing.T) <-chan time.Time
- func AssertEventually(t *testing.T, f func() bool)
- func Context(t *testing.T) (ctx context.Context)
- func IntToHex(n int) string
- func LoggerAssertMaxLevel(t *testing.T, lvl zapcore.Level) logger.Logger
- func MustNewSimTransactor(t *testing.T) *bind.TransactOpts
- func MustParseBigInt(t *testing.T, input string) *big.Int
- func MustParseURL(t testing.TB, input string) *url.URL
- func NewAddress() common.Address
- func NewAddressPtr() *common.Address
- func NewRandomEVMChainID() *big.Int
- func NewRandomInt64() int64
- func NewWSServer(t *testing.T, chainID *big.Int, callback JSONRPCHandler) (ts *testWSServer)
- func Random32Byte() (b [32]byte)
- func RandomizeName(n string) string
- func RequireLogMessage(t *testing.T, observedLogs *observer.ObservedLogs, msg string)
- func SkipShort(tb testing.TB, why string)
- func SkipShortDB(tb testing.TB)
- func TestCtx(t *testing.T) context.Context
- func WSServerURL(t *testing.T, s *httptest.Server) *url.URL
- func WaitForLogMessage(t *testing.T, observedLogs *observer.ObservedLogs, msg string)
- func WaitForLogMessageCount(t *testing.T, observedLogs *observer.ObservedLogs, msg string, count int)
- func WaitTimeout(t *testing.T) time.Duration
- func WaitWithTimeout(t *testing.T, ch <-chan struct{}, failMsg string)
- type JSONRPCHandler
Constants ¶
const DefaultWaitTimeout = 30 * time.Second
DefaultWaitTimeout is the default wait timeout. If you have a *testing.T, use WaitTimeout instead.
const (
// Password just a password we use everywhere for testing
Password = "16charlengthp4SsW0rD1!@#_"
)
const TestInterval = 10 * time.Millisecond
TestInterval is just a sensible poll interval that gives fast tests without risk of spamming
Variables ¶
var FixtureChainID = big.NewInt(0)
FixtureChainID matches the chain always added by fixtures.sql It is set to 0 since no real chain ever has this ID and allows a virtual "test" chain ID to be used without clashes
var SimulatedChainID = big.NewInt(1337)
SimulatedChainID is the chain ID for the go-ethereum simulated backend
Functions ¶
func AfterWaitTimeout ¶ added in v1.5.0
AfterWaitTimeout returns a channel that will send a time value when the WaitTimeout is reached
func AssertEventually ¶ added in v1.3.0
AssertEventually waits for f to return true
func LoggerAssertMaxLevel ¶ added in v1.4.0
LoggerAssertMaxLevel returns a test logger which is observed on cleanup and asserts that no lines were logged at a higher level.
func MustNewSimTransactor ¶ added in v1.4.0
func MustNewSimTransactor(t *testing.T) *bind.TransactOpts
MustNewSimTransactor returns a transactor for interacting with the geth simulated backend.
func MustParseBigInt ¶ added in v1.4.0
MustParseBigInt parses a big int value from string or fails the test
func MustParseURL ¶ added in v1.3.0
MustParseURL parses the URL or fails the test
func NewAddressPtr ¶ added in v1.5.0
func NewRandomEVMChainID ¶ added in v1.3.0
NewRandomEVMChainID returns a suitable random chain ID that will not conflict with fixtures
func NewRandomInt64 ¶ added in v1.3.0
func NewRandomInt64() int64
NewRandomInt64 returns a (non-cryptographically secure) random positive int64
func NewWSServer ¶ added in v1.3.0
func NewWSServer(t *testing.T, chainID *big.Int, callback JSONRPCHandler) (ts *testWSServer)
NewWSServer starts a websocket server which invokes callback for each message received. If chainID is set, then eth_chainId calls will be automatically handled.
func RandomizeName ¶ added in v1.6.0
RandomizeName appends a random UUID to the provided name
func RequireLogMessage ¶ added in v1.3.0
func RequireLogMessage(t *testing.T, observedLogs *observer.ObservedLogs, msg string)
RequireLogMessage fails the test if emitted logs don't contain the given message
func SkipShortDB ¶ added in v1.3.0
SkipShortDB skips tb during -short runs, and notes the DB dependency.
func WSServerURL ¶ added in v1.3.0
WSServerURL returns a ws:// url for the server
func WaitForLogMessage ¶ added in v1.3.0
func WaitForLogMessage(t *testing.T, observedLogs *observer.ObservedLogs, msg string)
WaitForLogMessage waits until at least one log message containing the specified msg is emitted. NOTE: This does not "pop" messages so it cannot be used multiple times to check for new instances of the same msg. See WaitForLogMessageCount instead.
Get a *observer.ObservedLogs like so:
observedZapCore, observedLogs := observer.New(zap.DebugLevel) lggr := logger.TestLogger(t, observedZapCore)
func WaitForLogMessageCount ¶ added in v1.3.0
func WaitForLogMessageCount(t *testing.T, observedLogs *observer.ObservedLogs, msg string, count int)
WaitForLogMessageCount waits until at least count log message containing the specified msg is emitted
func WaitTimeout ¶
WaitTimeout returns a timeout based on the test's Deadline, if available. Especially important to use in parallel tests, as their individual execution can get paused for arbitrary amounts of time.
func WaitWithTimeout ¶ added in v1.3.0
WaitWithTimeout waits for the channel to close (or receive anything) and fatals the test if the default wait timeout is exceeded