relayertest

package
v2.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package relayertest enables testing the relayer command-line interface from within Go unit tests.

Index

Constants

View Source
const (
	ZeroMnemonic   = "" /* 187-byte string literal not displayed */
	ZeroCosmosAddr = "cosmos1r5v5srda7xfth3hn2s26txvrcrntldjumt8mhl"
)

A fixed mnemonic and its resulting cosmos address, helpful for tests that need a mnemonic.

Variables

This section is empty.

Functions

This section is empty.

Types

type RunResult

type RunResult struct {
	Stdout, Stderr bytes.Buffer

	Err error
}

RunResult is the stdout and stderr resulting from a call to (*System).Run, and any error that was returned.

type System

type System struct {
	// Temporary directory to be injected as --home argument.
	HomeDir string
}

System is a system under test.

func NewSystem

func NewSystem(t *testing.T) *System

NewSystem creates a new system with a home dir associated with a temp dir belonging to t.

The returned System does not store a reference to t; some of its methods expect a *testing.T as an argument. This allows creating one instance of System to be shared with subtests.

func (*System) MustAddChain

func (s *System) MustAddChain(t *testing.T, chainName string, pcw cmd.ProviderConfigWrapper)

MustAddChain serializes pcw to disk and calls "chains add --file".

func (*System) MustGetConfig added in v2.3.0

func (s *System) MustGetConfig(t *testing.T) (config cmd.ConfigInputWrapper)

MustAddChain serializes pcw to disk and calls "chains add --file".

func (*System) MustRun

func (s *System) MustRun(t *testing.T, args ...string) RunResult

MustRun calls Run, but also calls t.Fatal if RunResult.Err is not nil.

func (*System) MustRunWithInput

func (s *System) MustRunWithInput(t *testing.T, in io.Reader, args ...string) RunResult

MustRunWithInput calls RunWithInput, but also calls t.Fatal if RunResult.Err is not nil.

func (*System) Run

func (s *System) Run(log *zap.Logger, args ...string) RunResult

Run calls s.RunC with context.Background().

func (*System) RunC

func (s *System) RunC(ctx context.Context, log *zap.Logger, args ...string) RunResult

RunC calls s.RunWithInputC with an empty stdin.

func (*System) RunWithInput

func (s *System) RunWithInput(log *zap.Logger, in io.Reader, args ...string) RunResult

RunWithInput is shorthand for RunWithInputC(context.Background(), ...).

func (*System) RunWithInputC

func (s *System) RunWithInputC(ctx context.Context, log *zap.Logger, in io.Reader, args ...string) RunResult

RunWithInputC executes the root command with the given context and args, providing in as the command's standard input, and returns a RunResult that has its Stdout and Stderr populated.

func (*System) WriteConfig added in v2.5.0

func (s *System) WriteConfig(t *testing.T, contents []byte) error

Jump to

Keyboard shortcuts

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