Documentation ¶
Index ¶
- Constants
- Variables
- func AddDeterministicValidatorsToGenesis(g *genesis.Genesis) error
- 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 ExecuteQGBHeights(ctx sdk.Context, qgbKeeper keeper.Keeper, beginHeight int64, endHeight int64) sdk.Context
- func ExecuteQGBHeightsWithTime(ctx sdk.Context, qgbKeeper keeper.Keeper, beginHeight int64, endHeight int64, ...) sdk.Context
- 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 NewTestApp() *app.App
- 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(_ *testing.T, capp *app.App, _ sdk.TxEncoder, kr keyring.Keyring, size int, ...) []coretypes.Tx
- func RandBlobTxsWithManualSequence(t *testing.T, _ sdk.TxEncoder, kr keyring.Keyring, size int, blobCount int, ...) []coretypes.Tx
- func RegisterEVMAddress(t *testing.T, input TestInput, valAddr sdk.ValAddress, ...)
- func SendTxWithManualSequence(t *testing.T, _ 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 SetupDeterministicGenesisState(testApp *app.App, pubKeys []cryptotypes.PubKey, balance int64, ...) (keyring.Keyring, []genesis.Account, error)
- func SetupTestAppWithGenesisValSet(cparams *tmproto.ConsensusParams, genAccounts ...string) (*app.App, keyring.Keyring)
- type EmptyAppOptions
- type TestInput
Constants ¶
const (
ChainID = "test-app"
)
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), } // HardcodedConsensusPrivKeys FixedConsensusPrivKeys = []tmed.PrivKey{ tmed.GenPrivKeyFromSecret([]byte("12345678901234567890123456389012")), tmed.GenPrivKeyFromSecret([]byte("12345678901234567890123456389013")), tmed.GenPrivKeyFromSecret([]byte("12345678901234567890123456389014")), tmed.GenPrivKeyFromSecret([]byte("12345678901234567890123456389015")), tmed.GenPrivKeyFromSecret([]byte("12345678901234567890123456389016")), } FixedNetWorkPrivKeys = []tmed.PrivKey{ tmed.GenPrivKeyFromSecret([]byte("12345678901234567890123456786012")), tmed.GenPrivKeyFromSecret([]byte("12345678901234567890123456786013")), tmed.GenPrivKeyFromSecret([]byte("12345678901234567890123456786014")), tmed.GenPrivKeyFromSecret([]byte("12345678901234567890123456786015")), tmed.GenPrivKeyFromSecret([]byte("12345678901234567890123456786016")), } // FixedMnemonics is a set of fixed mnemonics for testing. // Account names are: validator1, validator2, validator3, validator4, validator5 FixedMnemonics = []string{ "body world north giggle crop reduce height copper damp next verify orphan lens loan adjust inform utility theory now ranch motion opinion crowd fun", "body champion street fat bone above office guess waste vivid gift around approve elevator depth fiber alarm usual skirt like organ space antique silk", "cheap alpha render punch clap prize duty drive steel situate person radar smooth elegant over chronic wait danger thumb soft letter spatial acquire rough", "outdoor ramp suspect office disagree world attend vanish small wish capable fall wall soon damp session emotion chest toss viable meat host clerk truth", "ability evidence casino cram weasel chest brush bridge sister blur onion found glad own mansion amateur expect force fun dragon famous alien appear open", } // 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(100) // 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 GenesisTime = time.Date(2023, 1, 1, 1, 1, 1, 1, time.UTC).UTC()
Functions ¶
func AddDeterministicValidatorsToGenesis ¶ added in v1.14.0
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 ¶
func CreateValidator( t *testing.T, input TestInput, accAddr sdk.AccAddress, accPubKey ccrypto.PubKey, accountNumber uint64, valAddr sdk.ValAddress, consPubKey ccrypto.PubKey, stakingAmount cosmosmath.Int, )
func DirectQueryAccount ¶
func ExecuteQGBHeights ¶
func ExecuteQGBHeights(ctx sdk.Context, qgbKeeper keeper.Keeper, beginHeight int64, endHeight int64) sdk.Context
ExecuteQGBHeights executes the end exclusive range of heights specified by beginHeight and endHeight along with the QGB abci.EndBlocker on each one of them. Returns the updated context with block height advanced to endHeight.
func ExecuteQGBHeightsWithTime ¶
func ExecuteQGBHeightsWithTime(ctx sdk.Context, qgbKeeper keeper.Keeper, beginHeight int64, endHeight int64, blockInterval time.Duration) sdk.Context
ExecuteQGBHeightsWithTime executes the end exclusive range of heights specified by beginHeight and endHeight along with the QGB abci.EndBlocker on each one of them. Uses the interval to calculate the block header time.
func GenesisStateWithSingleValidator ¶
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 ¶
func MakeTestCodec() *codec.LegacyAmino
MakeTestCodec creates a legacy amino codec for testing
func MakeTestMarshaler ¶
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 NewTestApp ¶ added in v1.12.0
NewTestApp initializes a new app with a no-op logger and in-memory database.
func NewTestMsgCreateValidator ¶
func NewTestMsgCreateValidator( address sdk.ValAddress, pubKey ccrypto.PubKey, amt cosmosmath.Int, ) *stakingtypes.MsgCreateValidator
func NewTestMsgUnDelegateValidator ¶
func NewTestMsgUnDelegateValidator(address sdk.ValAddress, amt cosmosmath.Int) *stakingtypes.MsgUndelegate
func RandBlobTxsWithAccounts ¶
func RandBlobTxsWithAccounts( _ *testing.T, capp *app.App, _ 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 ¶
func RandBlobTxsWithManualSequence( t *testing.T, _ sdk.TxEncoder, kr keyring.Keyring, size int, blobCount int, randSize bool, chainid string, accounts []string, sequence, accountNum uint64, invalidSignature bool, ) []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 RegisterEVMAddress ¶
func RegisterEVMAddress( t *testing.T, input TestInput, valAddr sdk.ValAddress, evmAddr gethcommon.Address, )
func SendTxWithManualSequence ¶
func SendTxWithManualSequence( t *testing.T, _ 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 ¶
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 SetupDeterministicGenesisState ¶ added in v1.12.0
func SetupDeterministicGenesisState(testApp *app.App, pubKeys []cryptotypes.PubKey, balance int64, cparams *tmproto.ConsensusParams) (keyring.Keyring, []genesis.Account, error)
SetupDeterministicGenesisState sets genesis on initialized testApp with the provided arguments.
func SetupTestAppWithGenesisValSet ¶
func SetupTestAppWithGenesisValSet(cparams *tmproto.ConsensusParams, genAccounts ...string) (*app.App, keyring.Keyring)
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 no-op logger is set in app.
Types ¶
type EmptyAppOptions ¶ added in v1.12.0
type EmptyAppOptions struct{}
func (EmptyAppOptions) Get ¶ added in v1.12.0
func (ao EmptyAppOptions) Get(_ string) interface{}
Get implements AppOptions
type TestInput ¶
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 the QGB
func CreateTestEnv ¶
CreateTestEnv creates the keeper testing environment for QGB
func CreateTestEnvWithoutQGBKeysInit ¶
CreateTestEnvWithoutQGBKeysInit creates the keeper testing environment for the QGB
func SetupFiveValChain ¶
SetupFiveValChain does all the initialization for a 5 Validator chain using the keys here