Documentation ¶
Index ¶
- Constants
- Variables
- func AddAccount(addr sdk.AccAddress, appState app.GenesisState, cdc codec.Codec) (map[string]json.RawMessage, error)
- func AddDeterministicValidatorsToGenesis(g *genesis.Genesis) error
- func CreateValidator(t *testing.T, input TestInput, accAddr sdk.AccAddress, ...)
- func DirectQueryAccount(app *app.App, addr sdk.AccAddress) authtypes.AccountI
- func ExecuteBlobstreamHeights(ctx sdk.Context, bsKeeper keeper.Keeper, beginHeight int64, endHeight int64) sdk.Context
- func ExecuteBlobstreamHeightsWithTime(ctx sdk.Context, bsKeeper keeper.Keeper, beginHeight int64, endHeight int64, ...) sdk.Context
- func GenesisStateWithSingleValidator(testApp *app.App, genAccounts ...string) (app.GenesisState, *tmtypes.ValidatorSet, keyring.Keyring)
- func InitialiseTestAppWithGenesis(testApp *app.App, cparams *tmproto.ConsensusParams, ...) *app.App
- func MakeTestCodec() *codec.LegacyAmino
- func MakeTestMarshaler() codec.Codec
- func NewDefaultGenesisState(cdc codec.JSONCodec) app.GenesisState
- func NewTestApp() *app.App
- func NewTestAppWithGenesisSet(cparams *tmproto.ConsensusParams, genAccounts ...string) (*app.App, *tmtypes.ValidatorSet, keyring.Keyring)
- func NewTestAppWithGenesisSetAndMaxSquareSize(cparams *tmproto.ConsensusParams, maxSquareSize int, genAccounts ...string) (*app.App, *tmtypes.ValidatorSet, keyring.Keyring)
- 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, cfg client.TxConfig, kr keyring.Keyring, size int, ...) []coretypes.Tx
- func RandBlobTxsWithManualSequence(t *testing.T, cfg client.TxConfig, kr keyring.Keyring, size int, blobCount int, ...) []coretypes.Tx
- func RegisterEVMAddress(t *testing.T, input TestInput, valAddr sdk.ValAddress, ...)
- func SendTxWithManualSequence(t *testing.T, cfg client.TxConfig, kr keyring.Keyring, fromAcc, toAcc string, ...) coretypes.Tx
- func SendTxsWithAccounts(t *testing.T, capp *app.App, enc client.TxConfig, 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)
- func SetupTestAppWithGenesisValSetAndMaxSquareSize(cparams *tmproto.ConsensusParams, maxSquareSize int, genAccounts ...string) (*app.App, keyring.Keyring)
- func SetupTestAppWithUpgradeHeight(t *testing.T, upgradeHeight int64) (*app.App, keyring.Keyring)
- type EmptyAppOptions
- type TestInput
Constants ¶
const ChainID = testfactory.ChainID
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 AddAccount ¶
func AddAccount(addr sdk.AccAddress, appState app.GenesisState, cdc codec.Codec) (map[string]json.RawMessage, error)
AddAccount mimics the cli addAccount command, providing an account with an allocation of to "token" and "tia" tokens in the genesis state
func AddDeterministicValidatorsToGenesis ¶
AddDeterministicValidatorToGenesis adds a set of five validators to the genesis.
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 ExecuteBlobstreamHeights ¶
func ExecuteBlobstreamHeights(ctx sdk.Context, bsKeeper keeper.Keeper, beginHeight int64, endHeight int64) sdk.Context
ExecuteBlobstreamHeights executes the end exclusive range of heights specified by beginHeight and endHeight along with the Blobstream abci.EndBlocker on each one of them. Returns the updated context with block height advanced to endHeight.
func ExecuteBlobstreamHeightsWithTime ¶
func ExecuteBlobstreamHeightsWithTime(ctx sdk.Context, bsKeeper keeper.Keeper, beginHeight int64, endHeight int64, blockInterval time.Duration) sdk.Context
ExecuteBlobstreamHeightsWithTime executes the end exclusive range of heights specified by beginHeight and endHeight along with the Blobstream 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 InitialiseTestAppWithGenesis ¶
func InitialiseTestAppWithGenesis(testApp *app.App, cparams *tmproto.ConsensusParams, genesisState app.GenesisState) *app.App
InitialiseTestAppWithGenesis initializes the provided app with the provided genesis.
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 ¶
NewTestApp creates a new app instance with an empty memDB and a no-op logger.
func NewTestAppWithGenesisSet ¶
func NewTestAppWithGenesisSet(cparams *tmproto.ConsensusParams, genAccounts ...string) (*app.App, *tmtypes.ValidatorSet, keyring.Keyring)
NewTestAppWithGenesisSet initializes a new app with genesis accounts and returns the testApp, validator set and keyring.
func NewTestAppWithGenesisSetAndMaxSquareSize ¶
func NewTestAppWithGenesisSetAndMaxSquareSize(cparams *tmproto.ConsensusParams, maxSquareSize int, genAccounts ...string) (*app.App, *tmtypes.ValidatorSet, keyring.Keyring)
NewTestAppWithGenesisSetAndMaxSquareSize initializes a new app with genesis accounts and a specific max square size and returns the testApp, validator set and keyring.
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( t *testing.T, capp *app.App, cfg client.TxConfig, kr keyring.Keyring, size int, blobCount int, randSize bool, chainid string, accounts []string, extraOpts ...user.TxOption, ) []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, cfg client.TxConfig, 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, cfg client.TxConfig, kr keyring.Keyring, fromAcc, toAcc string, amount uint64, chainid string, sequence, accountNum uint64, opts ...user.TxOption, ) 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 client.TxConfig, kr keyring.Keyring, amount uint64, toAccount string, accounts []string, chainid string, extraOpts ...user.TxOption, ) []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 ¶
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 ¶
type EmptyAppOptions struct{}
func (EmptyAppOptions) Get ¶
func (ao EmptyAppOptions) Get(_ string) interface{}
Get implements AppOptions
type TestInput ¶
type TestInput struct { BlobstreamKeeper 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 Blobstream
func CreateTestEnv ¶
CreateTestEnv creates the keeper testing environment for Blobstream
func CreateTestEnvWithoutBlobstreamKeysInit ¶
CreateTestEnvWithoutBlobstreamKeysInit creates the keeper testing environment for Blobstream
func SetupFiveValChain ¶
SetupFiveValChain does all the initialization for a 5 Validator chain using the keys here