testcommon

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 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) (envBool bool, found bool)

helper function to look up a boolean from the environment variable key

func LookupEnvBoolWithDefault

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

helper function to look up a boolean from the environment variable key and return a passed-in default value if the environment variable is not set

func LookupEnvInt

func LookupEnvInt(t *testing.T, key string) (envInt int, found bool)

helper function to look up an integer from the environment variable key

func LookupEnvIntWithDefault

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

helper function to look up an integer from the environment variable key and return a passed-in default value if the environment variable is not set

func LookupEnvStringArray

func LookupEnvStringArray(t *testing.T, key string) (envStringArray []string, found bool)

helper function to look up a string array from the environment variable key

func LookupEnvStringArrayWithDefault

func LookupEnvStringArrayWithDefault(t *testing.T, key string, defaultValue []string) []string

helper function to look up a string array from the environment variable key and return a passed-in default value if the environment variable is not set

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.QueryServiceClient // query clients for emissions
	QueryMints         []minttypes.QueryServiceClient      // 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.QueryServiceClient

func (*Client) QueryGov

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

func (*Client) QueryMint

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

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

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

RandomKeyMap is a map that is O(1) for insertion, deletion, and random key selection Note that because rand.Rand is not safe for concurrent use, neither is RandomKeyMap

func NewRandomKeyMap

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

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

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

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

Get returns an element from the map

func (*RandomKeyMap[K, V]) GetAll

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

GetAll returns all elements from the map

func (*RandomKeyMap[K, V]) GetKeys

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

GetKeys returns all keys from the map

func (*RandomKeyMap[K, V]) Len

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

length of the map & slice

func (*RandomKeyMap[K, V]) RandomKey

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

Get a random key from the map

func (*RandomKeyMap[K, V]) Upsert

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) (rpcMode RpcConnectionType, found bool)

helper function to look up the rpc mode from the environment variable key

func LookupRpcModeWithDefault

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

helper function to look up the rpc mode from the environment variable key and return a passed-in default value if the environment variable is not set

func StringToRpcConnectionType

func StringToRpcConnectionType(t *testing.T, value string) RpcConnectionType

helper function to convert a string to a 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

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