cosmos-sdk/testutil/network/interface.go
Marko 03c3f8e71f
refactor(tests): testutil.Network as an interface (#18389)
Co-authored-by: Anmol <anmol1696@gmail.com>
2023-11-08 18:38:57 +00:00

45 lines
1.5 KiB
Go

package network
import (
"time"
"github.com/cosmos/cosmos-sdk/client"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/server"
srvconfig "github.com/cosmos/cosmos-sdk/server/config"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// NetworkI is an interface for a network of validators.
// It is used to abstract over the different network types (in-process, docker, etc.).
// if used there is a requirement to expose query and tx client for the nodes
type NetworkI interface {
// GetValidators returns the validators in the network
GetValidators() []ValidatorI
// WaitForNextBlock waits for the network to reach the next block
WaitForNextBlock() error
// WaitForHeight waits for the network to reach the given height
WaitForHeight(height int64) (int64, error)
// WaitForHeightWithTimeout waits for the network to reach the given height or times out
WaitForHeightWithTimeout(int64, time.Duration) (int64, error)
// RetryForBlocks retries the given function until it returns no error or the given number of blocks has passed
RetryForBlocks(retryFunc func() error, blocks int) error
// LatestHeight returns the latest height of the network
LatestHeight() (int64, error)
Cleanup()
}
// ValidatorI expose a validator's context and configuration
type ValidatorI interface {
GetCtx() *server.Context
GetAppConfig() *srvconfig.Config
GetAddress() sdk.AccAddress
GetValAddress() sdk.ValAddress
GetClientCtx() client.Context
GetAPIAddress() string
GetRPCAddress() string
GetPubKey() cryptotypes.PubKey
GetMoniker() string
}