testutil

package
v0.47.9-ics-lsm Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 20 Imported by: 1,027

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyMockIO

func ApplyMockIO(c *cobra.Command) (BufferReader, BufferWriter)

ApplyMockIO replaces stdin/out/err with buffers that can be used during testing. Returns an input BufferReader and an output BufferWriter.

func DefaultContext added in v0.43.0

func DefaultContext(key storetypes.StoreKey, tkey storetypes.StoreKey) sdk.Context

DefaultContext creates a sdk.Context with a fresh MemDB that can be used in tests.

func GenerateCoinKey added in v0.45.0

func GenerateCoinKey(algo keyring.SignatureAlgo, cdc codec.Codec) (sdk.AccAddress, string, error)

GenerateCoinKey generates a new key mnemonic along with its addrress.

func GenerateSaveCoinKey added in v0.45.0

func GenerateSaveCoinKey(
	keybase keyring.Keyring,
	keyName, mnemonic string,
	overwrite bool,
	algo keyring.SignatureAlgo,
) (sdk.AccAddress, string, error)

GenerateSaveCoinKey generates a new key mnemonic with its addrress. If mnemonic is provided then it's used for key generation. The key is saved in the keyring. The function returns error if overwrite=true and the key already exists.

func GetRequest added in v0.47.0

func GetRequest(url string) ([]byte, error)

GetRequest defines a wrapper around an HTTP GET request with a provided URL. An error is returned if the request or reading the body fails.

func GetRequestWithHeaders

func GetRequestWithHeaders(url string, headers map[string]string) ([]byte, error)

GetRequestWithHeaders defines a wrapper around an HTTP GET request with a provided URL and custom headers An error is returned if the request or reading the body fails.

func GetTempDir added in v0.46.0

func GetTempDir(t testing.TB) string

GetTempDir returns a writable temporary director for the test to use.

func PostRequest added in v0.47.0

func PostRequest(url string, contentType string, data []byte) ([]byte, error)

PostRequest defines a wrapper around an HTTP POST request with a provided URL and data. An error is returned if the request or reading the body fails.

func RandSliceElem added in v0.47.0

func RandSliceElem[E any](r *rand.Rand, elems []E) (E, bool)

func TempFile

func TempFile(t testing.TB) *os.File

TempFile returns a writable temporary file for the test to use.

func WriteToNewTempFile

func WriteToNewTempFile(t testing.TB, s string) *os.File

Write the given string to a new temporary file. Returns an open file for the test to use.

Types

type BufferReader

type BufferReader interface {
	io.Reader
	Reset(string)
}

BufferReader is implemented by types that read from a string buffer.

func ApplyMockIODiscardOutErr

func ApplyMockIODiscardOutErr(c *cobra.Command) BufferReader

ApplyMockIODiscardOutputs replaces a cobra.Command output and error streams with a dummy io.Writer. Replaces and returns the io.Reader associated to the cobra.Command input stream.

type BufferWriter

type BufferWriter interface {
	io.Writer
	Reset()
	Bytes() []byte
	String() string
}

BufferWriter is implemented by types that write to a buffer.

type TestAccount added in v0.47.0

type TestAccount struct {
	Name    string
	Address types.AccAddress
}

func CreateKeyringAccounts added in v0.47.0

func CreateKeyringAccounts(t *testing.T, kr keyring.Keyring, num int) []TestAccount

type TestContext added in v0.47.0

type TestContext struct {
	Ctx sdk.Context
	DB  *dbm.MemDB
	CMS store.CommitMultiStore
}

func DefaultContextWithDB added in v0.47.0

func DefaultContextWithDB(t *testing.T, key storetypes.StoreKey, tkey storetypes.StoreKey) TestContext

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.
db
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.
Package network implements and exposes a fully operational in-process Tendermint test network that consists of at least one or potentially many validators.
Package network implements and exposes a fully operational in-process Tendermint test network that consists of at least one or potentially many validators.

Jump to

Keyboard shortcuts

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