simapp

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2020 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StakePerAccount                        = "stake_per_account"
	InitiallyBondedValidators              = "initially_bonded_validators"
	OpWeightDeductFee                      = "op_weight_deduct_fee"
	OpWeightMsgSend                        = "op_weight_msg_send"
	OpWeightMsgMultiSend                   = "op_weight_msg_multisend"
	OpWeightMsgSetWithdrawAddress          = "op_weight_msg_set_withdraw_address"
	OpWeightMsgWithdrawDelegationReward    = "op_weight_msg_withdraw_delegation_reward"
	OpWeightMsgWithdrawValidatorCommission = "op_weight_msg_withdraw_validator_commission"
	OpWeightSubmitTextProposal             = "op_weight_submit_text_proposal"
	OpWeightSubmitCommunitySpendProposal   = "op_weight_submit_community_spend_proposal"
	OpWeightSubmitParamChangeProposal      = "op_weight_submit_param_change_proposal"
	OpWeightMsgDeposit                     = "op_weight_msg_deposit"
	OpWeightMsgVote                        = "op_weight_msg_vote"
	OpWeightMsgCreateValidator             = "op_weight_msg_create_validator"
	OpWeightMsgEditValidator               = "op_weight_msg_edit_validator"
	OpWeightMsgDelegate                    = "op_weight_msg_delegate"
	OpWeightMsgUndelegate                  = "op_weight_msg_undelegate"
	OpWeightMsgBeginRedelegate             = "op_weight_msg_begin_redelegate"
	OpWeightMsgUnjail                      = "op_weight_msg_unjail"
	OpWeightMsgMsgWhitelistAddress         = "op_weight_msg_whitelist_enterprise_address"
	OpWeightMsgRaisePurchaseOrder          = "op_weight_msg_purchase_enteprise_und"
	OpWeightMsgProcessUndPurchaseOrder     = "op_weight_msg_process_enteprise_und_purchase_order"
	OpWeightMsgRegisterWrkChain            = "op_weight_msg_register_wrkchain"
	OpWeightMsgRecordWrkChainBlock         = "op_weight_msg_record_wrkchain_block"
	OpWeightMsgRegisterBeacon              = "op_weight_msg_register_beacon"
	OpWeightMsgRecordBeaconTimestamp       = "op_weight_msg_record_beacon_timestamp"
)

Simulation parameter constants

Variables

View Source
var (
	// default home directories for the application CLI
	DefaultCLIHome = os.ExpandEnv("$HOME/.und_simapp")

	// default home directories for the application daemon
	DefaultNodeHome = os.ExpandEnv("$HOME/.und_simapp")

	// The module BasicManager is in charge of setting up basic,
	// non-dependant module elements, such as codec registration
	// and genesis verification.
	ModuleBasics = module.NewBasicManager(
		genutil.AppModuleBasic{},
		auth.AppModuleBasic{},
		bank.AppModuleBasic{},
		staking.AppModuleBasic{},
		mint.AppModuleBasic{},
		distr.AppModuleBasic{},
		gov.NewAppModuleBasic(paramsclient.ProposalHandler, distr.ProposalHandler),
		params.AppModuleBasic{},
		crisis.AppModuleBasic{},
		slashing.AppModuleBasic{},
		supply.AppModuleBasic{},
		enterprise.AppModule{},
		wrkchain.AppModule{},
		beacon.AppModule{},
		evidence.AppModuleBasic{},
	)
)
View Source
var (
	FlagGenesisFileValue        string
	FlagParamsFileValue         string
	FlagExportParamsPathValue   string
	FlagExportParamsHeightValue int
	FlagExportStatePathValue    string
	FlagExportStatsPathValue    string
	FlagSeedValue               int64
	FlagInitialBlockHeightValue int
	FlagNumBlocksValue          int
	FlagBlockSizeValue          int
	FlagLeanValue               bool
	FlagCommitValue             bool
	FlagOnOperationValue        bool // TODO: Remove in favor of binary search for invariant violation
	FlagAllInvariantsValue      bool

	FlagEnabledValue     bool
	FlagVerboseValue     bool
	FlagPeriodValue      uint
	FlagGenesisTimeValue int64
)

List of available flags for the simulator

Functions

func AddTestAddrs

func AddTestAddrs(app *UndSimApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sdk.AccAddress

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

func AppStateFn

func AppStateFn(cdc *codec.Codec, simManager *module.SimulationManager) simulation.AppStateFn

AppStateFn returns the initial application state using a genesis or the simulation parameters. It panics if the user provides files for both of them. If a file is not given for the genesis or the sim params, it creates a randomized one.

func AppStateRandomizedFn

func AppStateRandomizedFn(
	simManager *module.SimulationManager, r *rand.Rand, cdc *codec.Codec,
	accs []simulation.Account, genesisTimestamp time.Time, appParams simulation.AppParams,
) (json.RawMessage, []simulation.Account)

AppStateRandomizedFn creates calls each module's GenesisState generator function and creates the simulation params

func CheckBalance

func CheckBalance(t *testing.T, app *UndSimApp, addr sdk.AccAddress, exp sdk.Coins)

CheckBalance checks the balance of an account.

func ExportParamsToJSON

func ExportParamsToJSON(params simulation.Params, filepath string) error

ExportParamsToJSON util function to export the simulation parameters to JSON

func ExportStateToGenesisJSON added in v1.4.7

func ExportStateToGenesisJSON(app *UndSimApp, filepath string) error

ExportStateToGenesisJSON util function to export the app state to a new zero-height genesis JSON

func ExportStateToJSON

func ExportStateToJSON(app *UndSimApp, filepath string) error

ExportStateToJSON util function to export the app state to JSON

func GenSequenceOfTxs

func GenSequenceOfTxs(msgs []sdk.Msg, accNums []uint64, initSeqNums []uint64, numToGenerate int, priv ...crypto.PrivKey) []auth.StdTx

GenSequenceOfTxs generates a set of signed transactions of messages, such that they differ only by having the sequence numbers incremented between every transaction.

func GetMaccPerms

func GetMaccPerms() map[string][]string

GetMaccPerms returns a copy of the module account permissions

func GetSimulationLog

func GetSimulationLog(storeName string, sdr sdk.StoreDecoderRegistry, cdc *codec.Codec, kvAs, kvBs []tmkv.Pair) (log string)

GetSimulationLog unmarshals the KVPair's Value to the corresponding type based on the each's module store key and the prefix bytes of the KVPair's key.

func GetSimulatorFlags

func GetSimulatorFlags()

GetSimulatorFlags gets the values of all the available simulation flags

func MakeCodec

func MakeCodec() *codec.Codec

custom tx codec

func NewConfigFromFlags

func NewConfigFromFlags() simulation.Config

NewConfigFromFlags creates a simulation from the retrieved values of the flags.

func SetupUnitTestApp

func SetupUnitTestApp(isCheckTx bool, genAccs int, amt int64, testDenom string) (*UndSimApp, sdk.Context, TestAccount, []TestAccount)

SetupUnitTestApp creates a simApp and context for testing with some sensible chain defaults

func SignCheckDeliver

func SignCheckDeliver(
	t *testing.T, cdc *codec.Codec, app *bam.BaseApp, header abci.Header, msgs []sdk.Msg,
	accNums, seq []uint64, expSimPass, expPass bool, priv ...crypto.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.

Types

type GenesisState

type GenesisState map[string]json.RawMessage

The genesis state of the blockchain is represented here as a map of raw json messages key'd by a identifier string. The identifier is used to determine which module genesis information belongs to so it may be appropriately routed during init chain. Within this application default genesis information is retrieved from the ModuleBasicManager which populates json from each BasicModule object provided to it during init.

func NewDefaultGenesisState

func NewDefaultGenesisState() GenesisState

NewDefaultGenesisState generates the default state for the application.

type SimGenesisAccount

type SimGenesisAccount struct {
	*authtypes.BaseAccount

	// vesting account fields
	OriginalVesting  sdk.Coins `json:"original_vesting" yaml:"original_vesting"`   // total vesting coins upon initialization
	DelegatedFree    sdk.Coins `json:"delegated_free" yaml:"delegated_free"`       // delegated vested coins at time of delegation
	DelegatedVesting sdk.Coins `json:"delegated_vesting" yaml:"delegated_vesting"` // delegated vesting coins at time of delegation
	StartTime        int64     `json:"start_time" yaml:"start_time"`               // vesting start time (UNIX Epoch time)
	EndTime          int64     `json:"end_time" yaml:"end_time"`                   // vesting end time (UNIX Epoch time)

	// module account fields
	ModuleName        string   `json:"module_name" yaml:"module_name"`               // name of the module account
	ModulePermissions []string `json:"module_permissions" yaml:"module_permissions"` // permissions of module account
}

SimGenesisAccount defines a type that implements the GenesisAccount interface to be used for simulation accounts in the genesis state.

func (SimGenesisAccount) Validate

func (sga SimGenesisAccount) Validate() error

Validate checks for errors on the vesting and module account parameters

type TestAccount

type TestAccount struct {
	PrivKey ed25519.PrivKeyEd25519
	PubKey  crypto.PubKey
	Address sdk.AccAddress
}

type UndSimApp

type UndSimApp struct {
	*bam.BaseApp

	// keepers
	AccountKeeper    auth.AccountKeeper
	BankKeeper       bank.Keeper
	SupplyKeeper     supply.Keeper
	StakingKeeper    staking.Keeper
	SlashingKeeper   slashing.Keeper
	MintKeeper       mint.Keeper
	DistrKeeper      distr.Keeper
	GovKeeper        gov.Keeper
	CrisisKeeper     crisis.Keeper
	ParamsKeeper     params.Keeper
	WrkChainKeeper   wrkchain.Keeper
	EnterpriseKeeper enterprise.Keeper
	BeaconKeeper     beacon.Keeper
	EvidenceKeeper   evidence.Keeper
	// contains filtered or unexported fields
}

UndSimApp extends an ABCI application, but with most of its parameters exported. They are exported for convenience in creating helper functions, as object capabilities aren't needed for testing.

func NewUndSimApp

func NewUndSimApp(
	logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool,
	invCheckPeriod uint, baseAppOptions ...func(*bam.BaseApp),
) *UndSimApp

NewUndSimApp returns a reference to an initialized UndSimApp.

func Setup

func Setup(isCheckTx bool) *UndSimApp

Setup initializes a new UndSimApp. A Nop logger is set in UndSimApp.

func SetupWithGenesisAccounts

func SetupWithGenesisAccounts(genAccs []authexported.GenesisAccount) *UndSimApp

SetupWithGenesisAccounts initializes a new UndSimApp with the passed in genesis accounts.

func (*UndSimApp) BeginBlocker

func (app *UndSimApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock

application updates every begin block

func (*UndSimApp) Codec

func (app *UndSimApp) Codec() *codec.Codec

Codec returns simapp's codec

func (*UndSimApp) EndBlocker

func (app *UndSimApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock

application updates every end block

func (*UndSimApp) ExportAppStateAndValidators

func (app *UndSimApp) ExportAppStateAndValidators(
	forZeroHeight bool, jailWhiteList []string,
) (appState json.RawMessage, validators []tmtypes.GenesisValidator, err error)

ExportAppStateAndValidators exports the state of the application for a genesis file.

func (*UndSimApp) GetKey

func (app *UndSimApp) GetKey(storeKey string) *sdk.KVStoreKey

GetKey returns the KVStoreKey for the provided store key

func (*UndSimApp) GetTKey

func (app *UndSimApp) GetTKey(storeKey string) *sdk.TransientStoreKey

GetTKey returns the TransientStoreKey for the provided store key

func (*UndSimApp) InitChainer

func (app *UndSimApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain

application update at chain initialization

func (*UndSimApp) LoadHeight

func (app *UndSimApp) LoadHeight(height int64) error

load a particular height

func (*UndSimApp) ModuleAccountAddrs

func (app *UndSimApp) ModuleAccountAddrs() map[string]bool

ModuleAccountAddrs returns all the app's module account addresses.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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