tutil

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: GPL-3.0 Imports: 24 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 RequireEQ added in v0.15.0

func RequireEQ(tb testing.TB, a, b *big.Int, msgAndArgs ...any)

RequireEQ asserts that a and b are equal.

func RequireEventually added in v0.15.0

func RequireEventually(t *testing.T, ctx context.Context, fn func() bool, timeout time.Duration, interval time.Duration, msgAndArgs ...any)

RequireEventually runs the provided function until it returns true, the context is canceled, or the timeout is reached.

func RequireGT added in v0.15.0

func RequireGT(tb testing.TB, a, b *big.Int, msgAndArgs ...any)

RequireGT asserts that a is greater than b.

func RequireGTE added in v0.15.0

func RequireGTE(tb testing.TB, a, b *big.Int, msgAndArgs ...any)

RequireGTE asserts that a is greater than or equal to b.

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 RequireIsPositive added in v0.15.0

func RequireIsPositive(tb testing.TB, a *big.Int, msgAndArgs ...any)

RequireIsPositive asserts that a is positive.

func RequireIsZero added in v0.15.0

func RequireIsZero(tb testing.TB, a *big.Int, msgAndArgs ...any)

RequireIsZero asserts that a is zero.

func RequireLTE added in v0.15.0

func RequireLTE(tb testing.TB, a, b *big.Int, msgAndArgs ...any)

RequireLTE asserts that a is less than or equal to b.

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