testing

package
v3.0.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: GPL-3.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChainID               string = "BANDCHAIN"
	Port1                        = "port-1"
	Port2                        = "port-2"
	Channel1                     = "channel-1"
	Channel2                     = "channel-2"
	TestDefaultPrepareGas uint64 = 40000
	TestDefaultExecuteGas uint64 = 300000
	DefaultGenTxGas              = 1000000
)

Variables

View Source
var (
	Owner           Account
	Treasury        Account
	FeePayer        Account
	Alice           Account
	Bob             Account
	Carol           Account
	MissedValidator Account
	Validators      []Account
	DataSources     []oracletypes.DataSource
	OracleScripts   []oracletypes.OracleScript
	OwasmVM         *owasm.Vm
)
View Source
var (
	EmptyCoins          = sdk.Coins(nil)
	Coins1uband         = sdk.NewCoins(sdk.NewInt64Coin("uband", 1))
	Coins10uband        = sdk.NewCoins(sdk.NewInt64Coin("uband", 10))
	Coins11uband        = sdk.NewCoins(sdk.NewInt64Coin("uband", 11))
	Coins1000000uband   = sdk.NewCoins(sdk.NewInt64Coin("uband", 1000000))
	Coins99999999uband  = sdk.NewCoins(sdk.NewInt64Coin("uband", 99999999))
	Coins100000000uband = sdk.NewCoins(sdk.NewInt64Coin("uband", 100000000))
	BadCoins            = []sdk.Coin{{Denom: "uband", Amount: math.NewInt(-1)}}
)
View Source
var DefaultConsensusParams = &cmtproto.ConsensusParams{
	Block: &cmtproto.BlockParams{
		MaxBytes: 3000000,
		MaxGas:   -1,
	},
	Evidence: &cmtproto.EvidenceParams{
		MaxAgeNumBlocks: 100000,
		MaxAgeDuration:  48 * time.Hour,
		MaxBytes:        1048576,
	},
	Validator: &cmtproto.ValidatorParams{
		PubKeyTypes: []string{
			cmttypes.ABCIPubKeyTypeSecp256k1,
		},
	},
}

DefaultConsensusParams defines the default Tendermint consensus params used in TestingApp.

Functions

func CheckBalances

func CheckBalances(
	t *testing.T,
	ctx sdk.Context,
	bankKeeper bankkeeper.WrappedBankKeeper,
	address sdk.AccAddress,
	expected sdk.Coins,
)

func CheckErrorf

func CheckErrorf(t *testing.T, err error, errType error, msg string, a ...interface{})

CheckErrorf checks whether - error type is wrapped inside the given error - error match given message string combined with error type

func CreateTestingAppFn

func CreateTestingAppFn(t testing.TB) func() (ibctesting.TestingApp, map[string]json.RawMessage)

func GenSignedMockTx

func GenSignedMockTx(
	r *rand.Rand,
	txConfig client.TxConfig,
	msgs []sdk.Msg,
	feeAmt sdk.Coins,
	gas uint64,
	chainID string,
	accNums, accSeqs []uint64,
	priv ...cryptotypes.PrivKey,
) (sdk.Tx, error)

GenSignedMockTx generates a signed mock transaction.

func GenerateDataSources

func GenerateDataSources(homePath string) []oracletypes.DataSource

GenerateDataSources generates a set of data sources for the BandApp.

func GenerateOracleScripts

func GenerateOracleScripts(homePath string) []oracletypes.OracleScript

GenerateOracleScripts generates a set of oracle scripts for the BandApp.

func GenesisStateWithValSet

func GenesisStateWithValSet(app *band.BandApp, dir string) band.GenesisState

func MustGetBalances

func MustGetBalances(ctx sdk.Context, bankKeeper bankkeeper.WrappedBankKeeper, address sdk.AccAddress) sdk.Coins

func ParseTime

func ParseTime(t int64) time.Time

ParseTime is a helper function to parse from number to time.Time with UTC locale.

func SetupWithCustomHome

func SetupWithCustomHome(isCheckTx bool, dir string) *band.BandApp

SetupWithCustomHome initializes a new BandApp with a custom home directory

func SetupWithCustomHomeAndChainId

func SetupWithCustomHomeAndChainId(isCheckTx bool, dir, chainID string) *band.BandApp

func SignCheckDeliver

func SignCheckDeliver(
	t *testing.T, txCfg client.TxConfig, app *baseapp.BaseApp, header types.Header, msgs []sdk.Msg,
	chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey,
) (sdk.GasInfo, *sdk.Result, []types2.Event, error)

SignCheckDeliver checks a generated signed transaction and simulates a block commitment with the given transaction. A test assertion is made using the parameter 'expPass' against the result. A corresponding result is returned.

Types

type Account

type Account struct {
	PrivKey    cryptotypes.PrivKey
	PubKey     cryptotypes.PubKey
	Address    sdk.AccAddress
	ValAddress sdk.ValAddress
}

Account is a data structure to store key of test account.

func CreateArbitraryAccount

func CreateArbitraryAccount(r *rand.Rand) Account

CreateArbitraryAccount generates a random Account using a provided random number generator.

type GasMeterWrapper

type GasMeterWrapper struct {
	storetypes.GasMeter
	GasRecords []GasRecord
}

GasMeterWrapper wrap gas meter for testing purpose

func NewGasMeterWrapper

func NewGasMeterWrapper(meter storetypes.GasMeter) *GasMeterWrapper

NewGasMeterWrapper to wrap gas meters for testing purposes

func (*GasMeterWrapper) ConsumeGas

func (m *GasMeterWrapper) ConsumeGas(amount storetypes.Gas, descriptor string)

func (*GasMeterWrapper) CountDescriptor

func (m *GasMeterWrapper) CountDescriptor(descriptor string) int

func (*GasMeterWrapper) CountRecord

func (m *GasMeterWrapper) CountRecord(amount storetypes.Gas, descriptor string) int

type GasRecord

type GasRecord struct {
	Gas        storetypes.Gas
	Descriptor string
}

Jump to

Keyboard shortcuts

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