sims

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2022 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultGenTxGas = 10000000
	SimAppChainID   = "simulation-app"
)

SimAppChainID hardcoded chainID for simulation

View Source
const (
	DefaultWeightMsgSend                        int = 100
	DefaultWeightMsgMultiSend                   int = 10
	DefaultWeightMsgSetWithdrawAddress          int = 50
	DefaultWeightMsgWithdrawDelegationReward    int = 50
	DefaultWeightMsgWithdrawValidatorCommission int = 50
	DefaultWeightMsgFundCommunityPool           int = 50
	DefaultWeightMsgDeposit                     int = 100
	DefaultWeightMsgVote                        int = 67
	DefaultWeightMsgVoteWeighted                int = 33
	DefaultWeightMsgUnjail                      int = 100
	DefaultWeightMsgCreateValidator             int = 100
	DefaultWeightMsgEditValidator               int = 5
	DefaultWeightMsgDelegate                    int = 100
	DefaultWeightMsgUndelegate                  int = 100
	DefaultWeightMsgBeginRedelegate             int = 100
	DefaultWeightMsgCancelUnbondingDelegation   int = 100

	DefaultWeightCommunitySpendProposal int = 5
	DefaultWeightTextProposal           int = 5
	DefaultWeightParamChangeProposal    int = 5

	// feegrant
	DefaultWeightGrantAllowance  int = 100
	DefaultWeightRevokeAllowance int = 100
)

Default simulation operation weights for messages and gov proposals

Variables

View Source
var DefaultConsensusParams = &tmproto.ConsensusParams{
	Block: &tmproto.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 AddTestAddrs

func AddTestAddrs(bankKeeper bankkeeper.Keeper, stakingKeeper *stakingkeeper.Keeper, ctx sdk.Context, accNum int, accAmt math.Int) []sdk.AccAddress

AddTestAddrs constructs and returns accNum amount of accounts with an initial balance of accAmt in random order

func AddTestAddrsFromPubKeys

func AddTestAddrsFromPubKeys(bankKeeper bankkeeper.Keeper, stakingKeeper *stakingkeeper.Keeper, ctx sdk.Context, pubKeys []cryptotypes.PubKey, accAmt math.Int)

AddTestAddrsFromPubKeys adds the addresses into the SimApp providing only the public keys.

func AddTestAddrsIncremental

func AddTestAddrsIncremental(bankKeeper bankkeeper.Keeper, stakingKeeper *stakingkeeper.Keeper, ctx sdk.Context, accNum int, accAmt math.Int) []sdk.AccAddress

AddTestAddrsIncremental constructs and returns accNum amount of accounts with an initial balance of accAmt in random order

func ConvertAddrsToValAddrs

func ConvertAddrsToValAddrs(addrs []sdk.AccAddress) []sdk.ValAddress

ConvertAddrsToValAddrs converts the provided addresses to ValAddress.

func CreateIncrementalAccounts

func CreateIncrementalAccounts(accNum int) []sdk.AccAddress

createIncrementalAccounts is a strategy used by addTestAddrs() in order to generated addresses in ascending order.

func CreateRandomAccounts

func CreateRandomAccounts(accNum int) []sdk.AccAddress

CreateRandomAccounts is a strategy used by addTestAddrs() in order to generated addresses in random order.

func CreateRandomValidatorSet

func CreateRandomValidatorSet() (*tmtypes.ValidatorSet, error)

CreateRandomValidatorSet creates a validator set with one random validator

func CreateTestPubKeys

func CreateTestPubKeys(numPubKeys int) []cryptotypes.PubKey

CreateTestPubKeys returns a total of numPubKeys public keys in ascending order.

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 GenesisStateWithValSet

func GenesisStateWithValSet(codec codec.Codec, genesisState map[string]json.RawMessage,
	valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount,
	balances ...banktypes.Balance,
) (map[string]json.RawMessage, error)

GenesisStateWithValSet returns a new genesis state with the validator set

func NewAppOptionsWithFlagHome

func NewAppOptionsWithFlagHome(homePath string) servertypes.AppOptions

func NewPubKeyFromHex

func NewPubKeyFromHex(pk string) (res cryptotypes.PubKey)

NewPubKeyFromHex returns a PubKey from a hex string.

func Setup

func Setup(appConfig depinject.Config, extraOutputs ...interface{}) (*runtime.App, error)

Setup initializes a new runtime.App and can inject values into extraOutputs. It uses SetupWithConfiguration under the hood.

func SetupAtGenesis

func SetupAtGenesis(appConfig depinject.Config, extraOutputs ...interface{}) (*runtime.App, error)

SetupAtGenesis initializes a new runtime.App at genesis and can inject values into extraOutputs. It uses SetupWithConfiguration under the hood.

func SetupWithConfiguration

func SetupWithConfiguration(appConfig depinject.Config, startupConfig StartupConfig, extraOutputs ...interface{}) (*runtime.App, error)

SetupWithConfiguration initializes a new runtime.App. A Nop logger is set in runtime.App. appConfig usually load from a `app.yaml` with `appconfig.LoadYAML`, defines the application configuration. extraOutputs defines the extra outputs to be assigned by the dependency injector (depinject).

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, 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.

func TestAddr

func TestAddr(addr string, bech string) (sdk.AccAddress, error)

Types

type AppOptionsMap

type AppOptionsMap map[string]interface{}

AppOptionsMap is a stub implementing AppOptions which can get data from a map

func (AppOptionsMap) Get

func (m AppOptionsMap) Get(key string) interface{}

type EmptyAppOptions

type EmptyAppOptions struct{}

EmptyAppOptions is a stub implementing AppOptions

func (EmptyAppOptions) Get

func (ao EmptyAppOptions) Get(o string) interface{}

Get implements AppOptions

type GenerateAccountStrategy

type GenerateAccountStrategy func(int) []sdk.AccAddress

type GenesisAccount

type GenesisAccount struct {
	authtypes.GenesisAccount
	Coins sdk.Coins
}

type StartupConfig

type StartupConfig struct {
	ValidatorSet    func() (*tmtypes.ValidatorSet, error)
	BaseAppOption   runtime.BaseAppOption
	AtGenesis       bool
	GenesisAccounts []GenesisAccount
}

StartupConfig defines the startup configuration new a test application.

ValidatorSet defines a custom validator set to be validating the app. BaseAppOption defines the additional operations that must be run on baseapp before app start. AtGenesis defines if the app started should already have produced block or not.

func DefaultStartUpConfig

func DefaultStartUpConfig() StartupConfig

Jump to

Keyboard shortcuts

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