testutil

package
v0.10.1-v0-10-x.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: Apache-2.0 Imports: 57 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestAccName = "test-account"
)

Variables

View Source
var (
	// ModuleBasics is a mock module basic manager for testing
	ModuleBasics = app.ModuleBasics
	// TestingStakeParams is a set of staking params for testing
	TestingStakeParams = stakingtypes.Params{
		UnbondingTime:     100,
		MaxValidators:     10,
		MaxEntries:        10,
		HistoricalEntries: 10000,
		BondDenom:         "stake",
		MinCommissionRate: sdk.NewDecWithPrec(0, 0),
	}

	// ConsPrivKeys generate ed25519 ConsPrivKeys to be used for validator operator keys
	ConsPrivKeys = []ccrypto.PrivKey{
		ed25519.GenPrivKey(),
		ed25519.GenPrivKey(),
		ed25519.GenPrivKey(),
		ed25519.GenPrivKey(),
		ed25519.GenPrivKey(),
	}

	// ConsPubKeys holds the consensus public keys to be used for validator operator keys
	ConsPubKeys = []ccrypto.PubKey{
		ConsPrivKeys[0].PubKey(),
		ConsPrivKeys[1].PubKey(),
		ConsPrivKeys[2].PubKey(),
		ConsPrivKeys[3].PubKey(),
		ConsPrivKeys[4].PubKey(),
	}

	// AccPrivKeys generate secp256k1 pubkeys to be used for account pub keys
	AccPrivKeys = []ccrypto.PrivKey{
		secp256k1.GenPrivKey(),
		secp256k1.GenPrivKey(),
		secp256k1.GenPrivKey(),
		secp256k1.GenPrivKey(),
		secp256k1.GenPrivKey(),
	}

	// AccPubKeys holds the pub keys for the account keys
	AccPubKeys = []ccrypto.PubKey{
		AccPrivKeys[0].PubKey(),
		AccPrivKeys[1].PubKey(),
		AccPrivKeys[2].PubKey(),
		AccPrivKeys[3].PubKey(),
		AccPrivKeys[4].PubKey(),
	}

	// AccAddrs holds the sdk.AccAddresses
	AccAddrs = []sdk.AccAddress{
		sdk.AccAddress(AccPubKeys[0].Address()),
		sdk.AccAddress(AccPubKeys[1].Address()),
		sdk.AccAddress(AccPubKeys[2].Address()),
		sdk.AccAddress(AccPubKeys[3].Address()),
		sdk.AccAddress(AccPubKeys[4].Address()),
	}

	// ValAddrs holds the sdk.ValAddresses
	ValAddrs = []sdk.ValAddress{
		sdk.ValAddress(AccPubKeys[0].Address()),
		sdk.ValAddress(AccPubKeys[1].Address()),
		sdk.ValAddress(AccPubKeys[2].Address()),
		sdk.ValAddress(AccPubKeys[3].Address()),
		sdk.ValAddress(AccPubKeys[4].Address()),
	}

	// OrchPubKeys holds the pub keys for the orchestrator
	OrchPubKeys = []ccrypto.PubKey{
		OrchPrivKeys[0].PubKey(),
		OrchPrivKeys[1].PubKey(),
		OrchPrivKeys[2].PubKey(),
		OrchPrivKeys[3].PubKey(),
		OrchPrivKeys[4].PubKey(),
	}

	// OrchPrivKeys Orchestrator private keys
	OrchPrivKeys = []ccrypto.PrivKey{
		secp256k1.GenPrivKey(),
		secp256k1.GenPrivKey(),
		secp256k1.GenPrivKey(),
		secp256k1.GenPrivKey(),
		secp256k1.GenPrivKey(),
	}

	// OrchAddrs AccAddrs holds the sdk.AccAddresses
	OrchAddrs = []sdk.AccAddress{
		sdk.AccAddress(OrchPubKeys[0].Address()),
		sdk.AccAddress(OrchPubKeys[1].Address()),
		sdk.AccAddress(OrchPubKeys[2].Address()),
		sdk.AccAddress(OrchPubKeys[3].Address()),
		sdk.AccAddress(OrchPubKeys[4].Address()),
	}

	// EVMAddrs holds etheruem addresses
	EVMAddrs = initEVMAddrs(1000000) // TODO update 1000000 with a more realistic value

	// InitTokens holds the number of tokens to initialize an account with
	InitTokens = sdk.TokensFromConsensusPower(110, sdk.DefaultPowerReduction)

	// InitCoins holds the number of coins to initialize an account with
	InitCoins = sdk.NewCoins(sdk.NewCoin(TestingStakeParams.BondDenom, InitTokens))

	// StakingAmount holds the staking power to start a validator with
	StakingAmount = sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)
)
View Source
var DefaultConsensusParams = &abci.ConsensusParams{
	Block: &abci.BlockParams{
		MaxBytes: 200000,
		MaxGas:   2000000,
	},
	Evidence: &tmproto.EvidenceParams{
		MaxAgeNumBlocks: 302400,
		MaxAgeDuration:  504 * time.Hour,
		MaxBytes:        10000,
	},
	Validator: &tmproto.ValidatorParams{
		PubKeyTypes: []string{
			tmtypes.ABCIPubKeyTypeEd25519,
		},
	},
}

DefaultConsensusParams defines the default Tendermint consensus params used in SimApp testing.

Functions

func AddGenesisAccount

func AddGenesisAccount(addr sdk.AccAddress, appState app.GenesisState, cdc codec.Codec) (map[string]json.RawMessage, error)

AddGenesisAccount mimics the cli addGenesisAccount command, providing an account with an allocation of to "token" and "tia" tokens in the genesis state

func GenerateKeyringSigner

func GenerateKeyringSigner(t *testing.T, acct string) *types.KeyringSigner

GenerateKeyringSigner creates a types.KeyringSigner with keys generated for the provided accounts

func GenesisStateWithSingleValidator added in v0.5.0

func GenesisStateWithSingleValidator(t *testing.T, testApp *app.App) (app.GenesisState, *tmtypes.ValidatorSet)

SetupWithGenesisValSet initializes GenesisState with a single validator and genesis accounts that also act as delegators.

func MakeTestCodec added in v0.7.0

func MakeTestCodec() *codec.LegacyAmino

MakeTestCodec creates a legacy amino codec for testing

func MakeTestMarshaler added in v0.7.0

func MakeTestMarshaler() codec.Codec

MakeTestMarshaler creates a proto codec for use in testing

func NewDefaultGenesisState

func NewDefaultGenesisState(cdc codec.JSONCodec) app.GenesisState

NewDefaultGenesisState generates the default state for the application.

func NewTestMsgCreateValidator added in v0.7.0

func NewTestMsgCreateValidator(
	address sdk.ValAddress,
	pubKey ccrypto.PubKey,
	amt cosmosmath.Int,
	orchAddr sdk.AccAddress,
	evmAddr gethcommon.Address,
) *stakingtypes.MsgCreateValidator

func NewTestMsgUnDelegateValidator added in v0.7.0

func NewTestMsgUnDelegateValidator(address sdk.ValAddress, amt cosmosmath.Int) *stakingtypes.MsgUndelegate

func QueryWithOutProof added in v0.7.0

func QueryWithOutProof(clientCtx client.Context, hashHexStr string) (*rpctypes.ResultTx, error)

func SetupTestAppWithGenesisValSet added in v0.5.0

func SetupTestAppWithGenesisValSet(t *testing.T) *app.App

SetupTestAppWithGenesisValSet initializes a new app with a validator set and genesis accounts that also act as delegators. For simplicity, each validator is bonded with a delegation of one consensus engine unit in the default token of the app from first genesis account. A Nop logger is set in app.

Types

type TestInput added in v0.7.0

type TestInput struct {
	QgbKeeper      *keeper.Keeper
	AccountKeeper  authkeeper.AccountKeeper
	StakingKeeper  stakingkeeper.Keeper
	SlashingKeeper slashingkeeper.Keeper
	DistKeeper     distrkeeper.Keeper
	BankKeeper     bankkeeper.BaseKeeper
	Context        sdk.Context
	Marshaler      codec.Codec
	LegacyAmino    *codec.LegacyAmino
}

TestInput stores the various keepers required to test gravity

func CreateTestEnv added in v0.7.0

func CreateTestEnv(t *testing.T) TestInput

CreateTestEnv creates the keeper testing environment for gravity

func SetupFiveValChain added in v0.7.0

func SetupFiveValChain(t *testing.T) (TestInput, sdk.Context)

SetupFiveValChain does all the initialization for a 5 Validator chain using the keys here

func SetupTestChain added in v0.7.0

func SetupTestChain(t *testing.T, weights []uint64) (TestInput, sdk.Context)

SetupTestChain sets up a test environment with the provided validator voting weights

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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