testutil

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: Apache-2.0 Imports: 31 Imported by: 0

README

Testutil Directory

The x/common/testutil directory is not a cosmos-sdk module perse, but a collection of test utilities to make testing the other x/modules.

Documentation

Overview

Package nullify provides methods to init nil values structs for test assertion.

Index

Constants

This section is empty.

Variables

View Source
var Latin = TypeLatin{
	Letters:    "abcdefghijklmnopqrstuvwxyz",
	CapLetters: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
	Numbers:    "0123456789",
}

Functions

func AccAddress

func AccAddress() sdk.AccAddress

AccAddress returns a sample address (sdk.AccAddress) created using secp256k1. Note that AccAddress().String() can be used to get a string representation.

func AssertEventPresent added in v1.0.0

func AssertEventPresent(events sdk.Events, eventType string) error

AssertEventsPresent: Errors if the given event type is not present in events

func AssertEventsPresent added in v0.21.9

func AssertEventsPresent(events sdk.Events, eventTypes []string) (err error)

AssertEventsPresent: Errors if the given event types are not present in events

func BlankContext

func BlankContext(storeKeyName string) sdk.Context

func EventHasAttributeValue added in v0.21.6

func EventHasAttributeValue(abciEvent sdk.Event, key string, want string) error

EventHasAttributeValue parses the given ABCI event at a key to see if it matches (contains) the wanted value.

Args:

  • abciEvent: The event under test
  • key: The key for which we'll check the value
  • want: The desired value

func Fill

func Fill(x interface{}) interface{}

Fill analyze all struct fields and slices with reflection and initialize the nil and empty slices, structs, and pointers.

func FilterNewEvents added in v0.21.9

func FilterNewEvents(beforeEvents, afterEvents sdk.Events) sdk.Events

FilterNewEvents returns only the new events from afterEvents that were not present in beforeEvents

func GetPackageDir added in v1.0.0

func GetPackageDir() (string, error)

GetPackageDir: Returns the absolute path of the Golang package that calls this function.

func GovModuleAddr added in v1.0.0

func GovModuleAddr() sdk.AccAddress

func PrivKey added in v0.21.0

func PrivKey() (*secp256k1.PrivKey, sdk.AccAddress)

PrivKey returns a private key and corresponding on-chain address.

func PrivKeyAddressPairs

func PrivKeyAddressPairs(n int) (keys []cryptotypes.PrivKey, addrs []sdk.AccAddress)

PrivKeyAddressPairs generates (deterministically) a total of n private keys and addresses.

func RandLetters added in v1.0.0

func RandLetters(n int) string

func RequireContainsTypedEvent

func RequireContainsTypedEvent(t require.TestingT, ctx sdk.Context, event proto.Message)

func RequireNotHasTypedEvent

func RequireNotHasTypedEvent(t require.TestingT, ctx sdk.Context, event proto.Message)

RequireNotHasTypedEvent: Error if an event type matches the proto.Message name

func RunFunctionTests

func RunFunctionTests(t *testing.T, testCases []FunctionTestCase)

func SetupClientCtx added in v0.21.9

func SetupClientCtx(t *testing.T) context.Context

SetupClientCtx configures the client and server contexts and returns the resultant 'context.Context'. This is useful for executing CLI commands.

Types

type FunctionTestCase

type FunctionTestCase struct {
	Name string
	Test func()
}

type FunctionTestCases

type FunctionTestCases = []FunctionTestCase

type TypeLatin

type TypeLatin struct {
	Letters    string
	CapLetters string
	Numbers    string
}

Directories

Path Synopsis
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