Documentation ¶
Index ¶
- Constants
- Variables
- func AddGenesisAccount(addr sdk.AccAddress, appState app.GenesisState, cdc codec.Codec) (map[string]json.RawMessage, error)
- func CreateValidator(t *testing.T, input TestInput, accAddr sdk.AccAddress, ...)
- func DirectQueryAccount(app *app.App, addr sdk.AccAddress) authtypes.AccountI
- func GenesisStateWithSingleValidator(testApp *app.App, genAccounts ...string) (app.GenesisState, *tmtypes.ValidatorSet, keyring.Keyring)
- func MakeTestCodec() *codec.LegacyAmino
- func MakeTestMarshaler() codec.Codec
- func NewDefaultGenesisState(cdc codec.JSONCodec) app.GenesisState
- func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey ccrypto.PubKey, amt cosmosmath.Int, ...) *stakingtypes.MsgCreateValidator
- func NewTestMsgUnDelegateValidator(address sdk.ValAddress, amt cosmosmath.Int) *stakingtypes.MsgUndelegate
- func RandBlobTxsWithAccounts(t *testing.T, capp *app.App, enc sdk.TxEncoder, kr keyring.Keyring, size int, ...) []coretypes.Tx
- func RandBlobTxsWithManualSequence(t *testing.T, enc sdk.TxEncoder, kr keyring.Keyring, size int, blobCount int, ...) []coretypes.Tx
- func SendTxWithManualSequence(t *testing.T, enc sdk.TxEncoder, kr keyring.Keyring, fromAcc, toAcc string, ...) coretypes.Tx
- func SendTxsWithAccounts(t *testing.T, capp *app.App, enc sdk.TxEncoder, kr keyring.Keyring, ...) []coretypes.Tx
- func SetupTestAppWithGenesisValSet(genAccounts ...string) (*app.App, keyring.Keyring)
- type TestInput
Constants ¶
const (
ChainID = "testapp"
)
Variables ¶
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()), } // 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) )
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 CreateValidator ¶ added in v0.13.0
func CreateValidator( t *testing.T, input TestInput, accAddr sdk.AccAddress, accPubKey ccrypto.PubKey, accountNumber uint64, valAddr sdk.ValAddress, consPubKey ccrypto.PubKey, stakingAmount cosmosmath.Int, evmAddr gethcommon.Address, )
func DirectQueryAccount ¶ added in v0.12.0
func GenesisStateWithSingleValidator ¶ added in v0.5.0
func GenesisStateWithSingleValidator(testApp *app.App, genAccounts ...string) (app.GenesisState, *tmtypes.ValidatorSet, keyring.Keyring)
GenesisStateWithSingleValidator 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
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, evmAddr gethcommon.Address, ) *stakingtypes.MsgCreateValidator
func NewTestMsgUnDelegateValidator ¶ added in v0.7.0
func NewTestMsgUnDelegateValidator(address sdk.ValAddress, amt cosmosmath.Int) *stakingtypes.MsgUndelegate
func RandBlobTxsWithAccounts ¶ added in v0.12.0
func RandBlobTxsWithAccounts( t *testing.T, capp *app.App, enc sdk.TxEncoder, kr keyring.Keyring, size int, blobCount int, randSize bool, chainid string, accounts []string, extraOpts ...blobtypes.TxBuilderOption, ) []coretypes.Tx
RandBlobTxsWithAccounts will create random blob transactions using the provided configuration. The account info is queried directly from the application. One blob transaction is generated per account provided.
func RandBlobTxsWithManualSequence ¶ added in v0.12.0
func RandBlobTxsWithManualSequence( t *testing.T, enc sdk.TxEncoder, kr keyring.Keyring, size int, blobCount int, randSize bool, chainid string, accounts []string, sequence, accountNum uint64, ) []coretypes.Tx
RandBlobTxsWithManualSequence will create random blob transactions using the provided configuration. One blob transaction is generated per account provided. The sequence and account numbers are set manually using the provided values.
func SendTxWithManualSequence ¶ added in v0.12.0
func SendTxWithManualSequence( t *testing.T, enc sdk.TxEncoder, kr keyring.Keyring, fromAcc, toAcc string, amount uint64, chainid string, sequence, accountNum uint64, opts ...blobtypes.TxBuilderOption, ) coretypes.Tx
SendTxsWithAccounts will create a send transaction per account provided. The account info must be provided.
func SendTxsWithAccounts ¶ added in v0.12.0
func SendTxsWithAccounts( t *testing.T, capp *app.App, enc sdk.TxEncoder, kr keyring.Keyring, amount uint64, toAccount string, accounts []string, chainid string, extraOpts ...blobtypes.TxBuilderOption, ) []coretypes.Tx
SendTxsWithAccounts will create a send transaction per account provided, and send all funds to the "toAccount". The account info is queried directly from the application.
func SetupTestAppWithGenesisValSet ¶ added in v0.5.0
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
CreateTestEnv creates the keeper testing environment for QGB
func CreateTestEnvWithoutAttestationNonceInit ¶ added in v0.13.0
CreateTestEnvWithoutAttestationNonceInit creates the keeper testing environment for the QGB
func SetupFiveValChain ¶ added in v0.7.0
SetupFiveValChain does all the initialization for a 5 Validator chain using the keys here