Documentation ¶
Index ¶
- func CurryMsgGenerator[K interface{}, M sdk.Msg](k K, f func(K, *SimCtx, sdk.Context) (M, error)) func(*SimCtx, sdk.Context) (M, error)
- func GenAndDeliverTx(app *baseapp.BaseApp, txGen client.TxConfig, msg legacytx.LegacyMsg, ...) (simulation.OperationMsg, []simulation.FutureOperation, error)
- func GenAndDeliverTxWithRandFees(r *rand.Rand, app *baseapp.BaseApp, txGen client.TxConfig, ...) (simulation.OperationMsg, []simulation.FutureOperation, error)
- func RandLTBound[T constraints.Integer](sim *SimCtx, upperbound T) T
- func RandLTEBound[T constraints.Integer](sim *SimCtx, upperbound T) T
- func RandSelect[T interface{}](sim *SimCtx, args ...T) T
- func RemoveIndex(s sdk.Coins, index int) sdk.Coins
- type AccountKeeper
- type Action
- type ActionsWithMetadata
- type App
- type AppCreator
- type AppModuleSimulation
- type AppModuleSimulationGenesis
- type AppModuleSimulationPropertyCheck
- type BankKeeper
- type Frequency
- type ModuleGenesisGenerator
- type PropertyCheck
- type PubSubManager
- type SimAccountConstraint
- type SimCallbackFn
- type SimCtx
- func (sim SimCtx) AccountKeeper() AccountKeeper
- func (sim *SimCtx) AddAccount(acc simulation.Account)
- func (sim SimCtx) AppCodec() codec.Codec
- func (sim SimCtx) BankKeeper() BankKeeper
- func (sim SimCtx) BaseApp() *baseapp.BaseApp
- func (sim SimCtx) ChainID() string
- func (sim *SimCtx) FindAccount(address sdk.Address) (simulation.Account, bool)
- func (sim *SimCtx) GetRand() *rand.Rand
- func (sim *SimCtx) GetRandSubsetOfKDenoms(ctx sdk.Context, acc simulation.Account, k int) (sdk.Coins, bool)
- func (sim *SimCtx) GetSeededRand(seed string) *rand.Rand
- func (sim *SimCtx) RandCoinSubset(ctx sdk.Context, addr sdk.AccAddress, denoms []string) sdk.Coins
- func (sim *SimCtx) RandExponentialCoin(ctx sdk.Context, addr sdk.AccAddress) sdk.Coin
- func (sim *SimCtx) RandIntBetween(min, max int) int
- func (sim *SimCtx) RandPositiveInt(max sdk.Int) sdk.Int
- func (sim *SimCtx) RandStringOfLength(n int) string
- func (sim *SimCtx) RandSubsetCoins(coins sdk.Coins) sdk.Coins
- func (sim *SimCtx) RandTimestamp() time.Time
- func (sim *SimCtx) RandomAmount(max sdk.Int) sdk.Int
- func (sim *SimCtx) RandomDecAmount(max sdk.Dec) sdk.Dec
- func (sim *SimCtx) RandomExistingAddress() sdk.AccAddress
- func (sim *SimCtx) RandomFees(ctx sdk.Context, spendableCoins sdk.Coins) (sdk.Coins, error)
- func (sim *SimCtx) RandomSimAccount() simulation.Account
- func (sim *SimCtx) RandomSimAccountWithBalance(ctx sdk.Context) (simulation.Account, error)
- func (sim *SimCtx) RandomSimAccountWithConstraint(f SimAccountConstraint) (simulation.Account, bool)
- func (sim *SimCtx) RandomSimAccountWithKDenoms(ctx sdk.Context, k int) (simulation.Account, bool)
- func (sim *SimCtx) RandomSimAccountWithMinCoins(ctx sdk.Context, coins sdk.Coins) (simulation.Account, error)
- func (sim *SimCtx) SelAddrWithDenom(ctx sdk.Context, denom string) (simulation.Account, sdk.Coin, bool)
- func (sim *SimCtx) SelAddrWithDenoms(ctx sdk.Context, denoms []string) (simulation.Account, sdk.Coins, bool)
- func (sim *SimCtx) WrapRand(domainSeparator string) (wrappedSim *SimCtx, cleanup func())
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CurryMsgGenerator ¶
func GenAndDeliverTx ¶
func GenAndDeliverTx( app *baseapp.BaseApp, txGen client.TxConfig, msg legacytx.LegacyMsg, fees sdk.Coins, ctx sdk.Context, simAccount simulation.Account, ak AccountKeeper, moduleName string, ) (simulation.OperationMsg, []simulation.FutureOperation, error)
TODO: Must delete
func GenAndDeliverTxWithRandFees ¶
func GenAndDeliverTxWithRandFees( r *rand.Rand, app *baseapp.BaseApp, txGen client.TxConfig, msg legacytx.LegacyMsg, coinsSpentInMsg sdk.Coins, ctx sdk.Context, simAccount simulation.Account, ak AccountKeeper, bk BankKeeper, moduleName string, ) (simulation.OperationMsg, []simulation.FutureOperation, error)
TODO: Must delete
func RandLTBound ¶
func RandLTBound[T constraints.Integer](sim *SimCtx, upperbound T) T
func RandLTEBound ¶
func RandLTEBound[T constraints.Integer](sim *SimCtx, upperbound T) T
func RandSelect ¶
func RandSelect[T interface{}](sim *SimCtx, args ...T) T
Types ¶
type AccountKeeper ¶
type Action ¶
type Action interface { Name() string // I envision this frequency being provided from a config. // Module providers can optionally provide a default from an enum, // but this should not be the default. Frequency() Frequency // resultData is data that is eventually merkelized every block and // used to compare consistency across multiple simulation runs. Execute(*SimCtx, sdk.Context) ( OperationMsg simulation.OperationMsg, futureOps []simulation.FutureOperation, resultData []byte, err error) WithFrequency(w Frequency) Action }
Action represents a simulator action. The details of this struct are internal, we currently plan on maintaining 2 constructors for it. * weightedOperationAction - for legacy simulator compatibility * msgBasedAction - An easy API to go from creating a message via simctx to something simulator can deal with
type ActionsWithMetadata ¶
type App ¶
type App interface { GetBaseApp() *baseapp.BaseApp AppCodec() codec.Codec GetAccountKeeper() AccountKeeper GetBankKeeper() BankKeeper ModuleManager() module.Manager }
type AppCreator ¶
type AppModuleSimulation ¶
AppModuleSimulation defines the standard functions that every module should expose for the SDK blockchain simulator
type AppModuleSimulationGenesis ¶
type AppModuleSimulationGenesis interface { AppModuleSimulation // TODO: Come back and improve SimulationState interface SimulatorGenesisState(*module.SimulationState, *SimCtx) }
type AppModuleSimulationPropertyCheck ¶
type AppModuleSimulationPropertyCheck interface { module.AppModule PropertyChecks() []PropertyCheck }
type BankKeeper ¶
type ModuleGenesisGenerator ¶
type ModuleGenesisGenerator interface {
GenerateGenesisStates(simState *module.SimulationState, sim *SimCtx)
}
type PropertyCheck ¶
type PropertyCheck interface { // A property check listens for signals on the listed channels, that the simulator can emit. // Known channel types right now: // * Post-Action execute // * Pre-Action execute // * Block end (can make listener execute every Nth block end) SubscriptionKeys() []string Check(sim *SimCtx, ctx sdk.Context, key string, value interface{}) error }
type PubSubManager ¶
type SimAccountConstraint ¶
type SimAccountConstraint = func(account simulation.Account) bool
type SimCtx ¶
type SimCtx struct { Accounts []simulation.Account Cdc codec.JSONCodec // application codec // contains filtered or unexported fields }
TODO: Contemplate name better
func (SimCtx) AccountKeeper ¶
func (sim SimCtx) AccountKeeper() AccountKeeper
func (*SimCtx) AddAccount ¶
func (sim *SimCtx) AddAccount(acc simulation.Account)
func (SimCtx) BankKeeper ¶
func (sim SimCtx) BankKeeper() BankKeeper
func (*SimCtx) FindAccount ¶
FindAccount iterates over all the simulation accounts to find the one that matches the given address TODO: Benchmark time in here, we should probably just make a hashmap indexing this.
func (*SimCtx) GetRandSubsetOfKDenoms ¶
func (sim *SimCtx) GetRandSubsetOfKDenoms(ctx sdk.Context, acc simulation.Account, k int) (sdk.Coins, bool)
GetRandSubsetOfKDenoms returns a random subset of coins of k unique denoms from the provided account TODO: Write unit test
func (*SimCtx) GetSeededRand ¶
TODO: Consider rename to SeededRand() or DomainSeparatedRand
func (*SimCtx) RandCoinSubset ¶
func (*SimCtx) RandExponentialCoin ¶
RandGeometricCoin uniformly samples a denom from the addr's balances. Then it samples an Exponentially distributed amount of the addr's coins, with rate = 10. (Meaning that on average it samples 10% of the chosen balance) Pre-condition: Addr must have a spendable balance
func (*SimCtx) RandIntBetween ¶
RandIntBetween returns a random int between two numbers, inclusive of min, exclusive of max.
func (*SimCtx) RandPositiveInt ¶
RandPositiveInt get a rand positive sdk.Int
func (*SimCtx) RandStringOfLength ¶
RandStringOfLength generates a random string of a particular length
func (*SimCtx) RandSubsetCoins ¶
returns random subset of the provided coins will return at least one coin unless coins argument is empty or malformed i.e. 0 amt in coins
func (*SimCtx) RandTimestamp ¶
RandTimestamp generates a random timestamp
func (*SimCtx) RandomAmount ¶
RandomAmount generates a random amount that is biased to return max and 0.
func (*SimCtx) RandomDecAmount ¶
RandomDecAmount generates a random decimal amount Note: The range of RandomDecAmount includes max, and is, in fact, biased to return max as well as 0.
func (*SimCtx) RandomExistingAddress ¶
func (sim *SimCtx) RandomExistingAddress() sdk.AccAddress
func (*SimCtx) RandomFees ¶
RandomFees returns a random fee by selecting a random coin denomination and amount from the account's available balance. If the user doesn't have enough funds for paying fees, it returns empty coins.
func (*SimCtx) RandomSimAccount ¶
func (sim *SimCtx) RandomSimAccount() simulation.Account
func (*SimCtx) RandomSimAccountWithBalance ¶
func (*SimCtx) RandomSimAccountWithConstraint ¶
func (sim *SimCtx) RandomSimAccountWithConstraint(f SimAccountConstraint) (simulation.Account, bool)
returns acc, accExists := sim.RandomSimAccountWithConstraint(f) where acc is a uniformly sampled account from all accounts satisfying the constraint f a constraint is satisfied for an account `acc` if f(acc) = true accExists is false, if there is no such account.
func (*SimCtx) RandomSimAccountWithKDenoms ¶
RandomSimAccountWithKDenoms returns an account that possesses k unique denoms
func (*SimCtx) RandomSimAccountWithMinCoins ¶
func (*SimCtx) SelAddrWithDenom ¶
func (sim *SimCtx) SelAddrWithDenom(ctx sdk.Context, denom string) (simulation.Account, sdk.Coin, bool)
SelAddrWithDenom attempts to find an address with the provided denom. This function returns (account, randSubsetCoins, found), so if found = false, then no such address exists. randSubsetCoins is a random subset of the provided denoms, if the account is found. TODO: Write unit test
func (*SimCtx) SelAddrWithDenoms ¶
func (sim *SimCtx) SelAddrWithDenoms(ctx sdk.Context, denoms []string) (simulation.Account, sdk.Coins, bool)
Returns (account, randSubsetCoins, found), so if found = false, then no such address exists. randSubsetCoins is a random subset of the provided denoms, if the account is found. TODO: Write unit test