tutil

package
v0.8.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package tutil provides test utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepRPCTestConfig

func PrepRPCTestConfig(t *testing.T) *config.Config

PrepRPCTestConfig creates the require cometbft config on disk for rpctest package to work with halo app.

func RandomAddress

func RandomAddress() common.Address

RandomAddress returns a random 20-byte ethereum address.

func RandomAvailablePort

func RandomAvailablePort(t *testing.T) int

func RandomBytes

func RandomBytes(l int) []byte

RandomBytes returns a random byte slice of length l.

func RandomHash

func RandomHash() common.Hash

RandomHash returns a random 32-byte 256-bit hash.

func RandomListenAddress

func RandomListenAddress(t *testing.T) string

func RequireGoldenBytes

func RequireGoldenBytes(t *testing.T, data []byte, opts ...func(*string))

RequireGoldenBytes asserts that a golden testdata file exists containing the exact data. This is heavily inspired from https://github.com/sebdah/goldie.

func RequireGoldenJSON

func RequireGoldenJSON(t *testing.T, data any, opts ...func(*string))

RequireGoldenJSON asserts that a golden testdata file exists containing the JSON serialized form of the data object. This is heavily inspired from https://github.com/sebdah/goldie.

func RequireNoError

func RequireNoError(tb testing.TB, err error)

RequireNoError asserts that err is nil. It also logs the error to show the stacktrace.

This can be used instead of require.NoError(t, err) to show the stacktrace in case of error.

func TempDir

func TempDir(t *testing.T) string

TempDir creates a temporary directory with a random name, as opposed to t.TempDir which uses consecutive numbers per test (001, 002 ...).

func WithFilename

func WithFilename(name string) func(*string)

WithFilename configures a custom golden test filename.

Types

This section is empty.

Jump to

Keyboard shortcuts

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