Documentation
¶
Overview ¶
Package tutil provides test utilities.
Index ¶
- func PrepRPCTestConfig(t *testing.T) *config.Config
- func RandomAddress() common.Address
- func RandomAvailablePort(t *testing.T) int
- func RandomBytes(l int) []byte
- func RandomHash() common.Hash
- func RandomListenAddress(t *testing.T) string
- func RequireEQ(tb testing.TB, a, b *big.Int, msgAndArgs ...any)
- func RequireEventually(t *testing.T, ctx context.Context, fn func() bool, timeout time.Duration, ...)
- func RequireGT(tb testing.TB, a, b *big.Int, msgAndArgs ...any)
- func RequireGTE(tb testing.TB, a, b *big.Int, msgAndArgs ...any)
- func RequireGoldenBytes(t *testing.T, data []byte, opts ...func(*string))
- func RequireGoldenJSON(t *testing.T, data any, opts ...func(*string))
- func RequireIsPositive(tb testing.TB, a *big.Int, msgAndArgs ...any)
- func RequireIsZero(tb testing.TB, a *big.Int, msgAndArgs ...any)
- func RequireLTE(tb testing.TB, a, b *big.Int, msgAndArgs ...any)
- func RequireNoError(tb testing.TB, err error)
- func TempDir(t *testing.T) string
- func WithFilename(name string) func(*string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrepRPCTestConfig ¶
PrepRPCTestConfig creates the require cometbft config on disk for rpctest package to work with halo app.
func RandomAddress ¶
RandomAddress returns a random 20-byte ethereum address.
func RandomAvailablePort ¶
func RandomBytes ¶
RandomBytes returns a random byte slice of length l.
func RandomListenAddress ¶
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 RequireGTE ¶ added in v0.15.0
RequireGTE asserts that a is greater than or equal to b.
func RequireGoldenBytes ¶
RequireGoldenBytes asserts that a golden testdata file exists containing the exact data. This is heavily inspired from https://github.com/sebdah/goldie.
func RequireGoldenJSON ¶
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
RequireIsPositive asserts that a is positive.
func RequireIsZero ¶ added in v0.15.0
RequireIsZero asserts that a is zero.
func RequireLTE ¶ added in v0.15.0
RequireLTE asserts that a is less than or equal to b.
func RequireNoError ¶
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 ¶
TempDir creates a temporary directory with a random name, as opposed to t.TempDir which uses consecutive numbers per test (001, 002 ...).
func WithFilename ¶
WithFilename configures a custom golden test filename.
Types ¶
This section is empty.