testcommon

package
v0.3.1-devnet-upgrade-... Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LookupEnvBool

func LookupEnvBool(t *testing.T, key string, defaultValue bool) bool

func LookupEnvInt

func LookupEnvInt(t *testing.T, key string, defaultValue int) int

func LookupEnvStringArray

func LookupEnvStringArray(key string, defaultValue []string) []string

Types

type Client

type Client struct {
	RpcConnectionType  RpcConnectionType               // what kind of rpc connection to use
	Clients            []cosmosclient.Client           // clients to attach to
	QueryAuths         []authtypes.QueryClient         // query clients for auth
	QueryBanks         []banktypes.QueryClient         // query clients for bank
	QueryDistributions []distributiontypes.QueryClient // query clients for distribution
	QueryEmissionses   []emissionstypes.QueryClient    // query clients for emissions
	QueryMints         []minttypes.QueryClient         // query clients for mint
	QueryGovs          []govtypesv1.QueryClient        // query clients for gov
	QueryUpgrades      []upgradetypes.QueryClient      // query clients for upgrades
	RpcCounterSeed     int64                           // if round-robin which RPC to use next, if random, seed to use
	RpcCounterMutex    *sync.Mutex                     // mutex for the counter
	Rand               *rand.Rand                      // random number generator
	// contains filtered or unexported fields
}

where to get ahold of a node

func NewClient

func NewClient(
	t *testing.T,
	rpcConnectionType RpcConnectionType,
	nodeRpcAddresses []string,
	alloraHomeDir string,
	seed int64,
) Client

create a new appchain client that we can use

func (*Client) AccountRegistryCreate

func (c *Client) AccountRegistryCreate(name string) (
	acc cosmosaccount.Account,
	mnemonic string,
	err error,
)

func (*Client) AccountRegistryGetByName

func (c *Client) AccountRegistryGetByName(name string) (
	cosmosaccount.Account,
	error,
)

func (*Client) BlockHeight

func (c *Client) BlockHeight(ctx context.Context) (int64, error)

func (*Client) BroadcastTx

func (c *Client) BroadcastTx(
	ctx context.Context,
	account cosmosaccount.Account,
	msgs ...sdktypes.Msg,
) (cosmosclient.Response, error)

func (*Client) Context

func (c *Client) Context() sdkclient.Context

func (*Client) QueryAuth

func (c *Client) QueryAuth() authtypes.QueryClient

/ Accessors for Query Clients. These don't have to be concurrency aware because they are read only, and the RPC endpoint should handle concurrency.

func (*Client) QueryBank

func (c *Client) QueryBank() banktypes.QueryClient

func (*Client) QueryDistribution

func (c *Client) QueryDistribution() distributiontypes.QueryClient

func (*Client) QueryEmissions

func (c *Client) QueryEmissions() emissionstypes.QueryClient

func (*Client) QueryGov

func (c *Client) QueryGov() govtypesv1.QueryClient

func (*Client) QueryMint

func (c *Client) QueryMint() minttypes.QueryClient

func (*Client) QueryUpgrade

func (c *Client) QueryUpgrade() upgradetypes.QueryClient

func (*Client) WaitForBlockHeight

func (c *Client) WaitForBlockHeight(ctx context.Context, height int64) error

func (*Client) WaitForNextBlock

func (c *Client) WaitForNextBlock(ctx context.Context) error

func (*Client) WaitForTx

func (c *Client) WaitForTx(ctx context.Context, hash string) (*coretypes.ResultTx, error)

type RandomKeyMap added in v0.2.13

type RandomKeyMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewRandomKeyMap added in v0.2.13

func NewRandomKeyMap[K comparable, V any](r *rand.Rand) *RandomKeyMap[K, V]

RandomKeyMap is a map that is O(1) for insertion, deletion, and random key selection

func (*RandomKeyMap[K, V]) Delete added in v0.2.13

func (rkm *RandomKeyMap[K, V]) Delete(k K)

Remove element from the map by swapping in the last element in its place.

func (*RandomKeyMap[K, V]) Filter added in v0.2.13

func (rkm *RandomKeyMap[K, V]) Filter(f func(K) bool) ([]K, []V)

Filter returns all elements from the map that satisfy the predicate

func (*RandomKeyMap[K, V]) Get added in v0.2.13

func (rkm *RandomKeyMap[K, V]) Get(k K) (V, bool)

Get returns an element from the map

func (*RandomKeyMap[K, V]) GetAll added in v0.2.13

func (rkm *RandomKeyMap[K, V]) GetAll() []V

GetAll returns all elements from the map

func (*RandomKeyMap[K, V]) Len added in v0.2.13

func (rkm *RandomKeyMap[K, V]) Len() int

length of the map & slice

func (*RandomKeyMap[K, V]) RandomKey added in v0.2.13

func (rkm *RandomKeyMap[K, V]) RandomKey() (*K, error)

Get a random key from the map

func (*RandomKeyMap[K, V]) Upsert added in v0.2.13

func (rkm *RandomKeyMap[K, V]) Upsert(k K, v V)

Upsert element into the map

type RpcConnectionType

type RpcConnectionType = uint8
const (
	SingleRpc RpcConnectionType = iota
	RoundRobin
	RandomBasedOnDeterministicSeed
)

func LookupRpcMode

func LookupRpcMode(t *testing.T, key string, defaultValue RpcConnectionType) RpcConnectionType

type TestConfig

type TestConfig struct {
	T              *testing.T
	Client         Client                // a testcommon.Client which holds several cosmosclient.Client instances
	AlloraHomeDir  string                // home directory for the allora keystore
	FaucetAcc      cosmosaccount.Account // account info for the faucet
	FaucetAddr     string                // faucets address, string encoded bech32
	UpshotAcc      cosmosaccount.Account // account info for the upshot account
	UpshotAddr     string                // upshot address, string encoded bech32
	AliceAcc       cosmosaccount.Account // account info for the alice test account
	AliceAddr      string                // alice address, string encoded bech32
	BobAcc         cosmosaccount.Account // account info for the bob test account
	BobAddr        string                // bob address, string encoded bech32
	Validator0Acc  cosmosaccount.Account // account info for the validator0 test account
	Validator0Addr string                // validator0 address, string encoded bech32
	Validator1Acc  cosmosaccount.Account // account info for the validator1 test account
	Validator1Addr string                // validator1 address, string encoded bech32
	Validator2Acc  cosmosaccount.Account // account info for the validator2 test account
	Validator2Addr string                // validator2 address, string encoded bech32
	Cdc            codec.Codec           // common codec for encoding/decoding
	Seed           int                   // global non-mutable seed used for naming the test run
}

handle to various node data

func NewTestConfig

func NewTestConfig(
	t *testing.T,
	rpcConnectionType RpcConnectionType,
	nodeRpcAddresses []string,
	alloraHomeDir string,
	seed int,
) TestConfig

create a new config that we can use

type ValueIndex added in v0.2.13

type ValueIndex[V any] struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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