Documentation ¶
Index ¶
- func AddAccount(acc simulation.Account, accs []simulation.Account) []simulation.Account
- func FindAccount(address sdk.Address, accs []simulation.Account) (simulation.Account, bool)
- func GetRandSubsetOfKDenoms(ctx sdk.Context, r *rand.Rand, acc simulation.Account, k int, bk BankKeeper) (sdk.Coins, bool)
- func RandCoin(r *rand.Rand, coins sdk.Coins) sdk.Coins
- func RandCoinSubsetFromBalance(ctx sdk.Context, r *rand.Rand, addr sdk.AccAddress, denoms []string, ...) (sdk.Coins, error)
- func RandExponentialCoin(r *rand.Rand, coin sdk.Coin) sdk.Coin
- func RandExponentialCoinFromBalance(ctx sdk.Context, r *rand.Rand, addr sdk.AccAddress, bk BankKeeper) sdk.Coin
- func RandIntBetween(r *rand.Rand, min, max int) int
- func RandLTBound[T constraints.Integer](r *rand.Rand, upperbound T) T
- func RandLTEBound[T constraints.Integer](r *rand.Rand, upperbound T) T
- func RandPositiveInt(r *rand.Rand, max sdkmath.Int) (sdkmath.Int, error)
- func RandSelect[T interface{}](r *rand.Rand, args ...T) T
- func RandStringOfLength(r *rand.Rand, n int) string
- func RandSubsetCoins(r *rand.Rand, coins sdk.Coins) sdk.Coins
- func RandTimestamp(r *rand.Rand) time.Time
- func RandomAmount(r *rand.Rand, max sdkmath.Int) sdkmath.Int
- func RandomDecAmount(r *rand.Rand, max sdk.Dec) sdk.Dec
- func RandomExistingAddress(r *rand.Rand, accs []simulation.Account) sdk.AccAddress
- func RandomFees(r *rand.Rand, spendableCoins sdk.Coins) (sdk.Coins, error)
- func RandomSimAccount(r *rand.Rand, accs []simulation.Account) simulation.Account
- func RandomSimAccountWithBalance(ctx sdk.Context, r *rand.Rand, accs []simulation.Account, bk BankKeeper) (simulation.Account, error)
- func RandomSimAccountWithConstraint(r *rand.Rand, f SimAccountConstraint, accs []simulation.Account) (simulation.Account, bool)
- func RandomSimAccountWithKDenoms(ctx sdk.Context, r *rand.Rand, accs []simulation.Account, k int, bk BankKeeper) (simulation.Account, bool)
- func RandomSimAccountWithMinCoins(ctx sdk.Context, r *rand.Rand, accs []simulation.Account, coins sdk.Coins, ...) (simulation.Account, error)
- func RemoveIndex(s sdk.Coins, index int) sdk.Coins
- func SelAddrWithDenom(ctx sdk.Context, r *rand.Rand, accs []simulation.Account, denom string, ...) (simulation.Account, sdk.Coin, bool)
- func SelAddrWithDenoms(ctx sdk.Context, r *rand.Rand, accs []simulation.Account, denoms []string, ...) (simulation.Account, sdk.Coins, bool)
- type AccountKeeper
- type BankKeeper
- type DistrKeeper
- type SimAccountConstraint
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddAccount ¶
func AddAccount(acc simulation.Account, accs []simulation.Account) []simulation.Account
func FindAccount ¶
func FindAccount(address sdk.Address, accs []simulation.Account) (simulation.Account, bool)
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 GetRandSubsetOfKDenoms ¶
func GetRandSubsetOfKDenoms(ctx sdk.Context, r *rand.Rand, acc simulation.Account, k int, bk BankKeeper) (sdk.Coins, bool)
GetRandSubsetOfKDenoms returns a random subset of coins of k unique denoms from the provided account TODO: Write unit test.
func RandExponentialCoin ¶
RandExponentialCoin 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 RandExponentialCoinFromBalance ¶
func RandExponentialCoinFromBalance(ctx sdk.Context, r *rand.Rand, addr sdk.AccAddress, bk BankKeeper) sdk.Coin
RandExponentialCoinFromBalance 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 RandIntBetween ¶
RandIntBetween returns a random int between two numbers inclusively.
func RandLTBound ¶
func RandLTBound[T constraints.Integer](r *rand.Rand, upperbound T) T
func RandLTEBound ¶
func RandLTEBound[T constraints.Integer](r *rand.Rand, upperbound T) T
func RandPositiveInt ¶
RandPositiveInt get a rand positive sdkmath.Int.
func RandSelect ¶
func RandStringOfLength ¶
RandStringOfLength generates a random string of a particular length.
func RandSubsetCoins ¶
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 RandTimestamp ¶
RandTimestamp generates a random timestamp.
func RandomAmount ¶
RandomAmount generates a random amount. Note: The range of RandomAmount includes max, and is, in fact, biased to return max as well as 0.
func 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 RandomExistingAddress ¶
func RandomExistingAddress(r *rand.Rand, accs []simulation.Account) sdk.AccAddress
func 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 RandomSimAccount ¶
func RandomSimAccount(r *rand.Rand, accs []simulation.Account) simulation.Account
func RandomSimAccountWithBalance ¶
func RandomSimAccountWithBalance(ctx sdk.Context, r *rand.Rand, accs []simulation.Account, bk BankKeeper) (simulation.Account, error)
func RandomSimAccountWithConstraint ¶
func RandomSimAccountWithConstraint(r *rand.Rand, f SimAccountConstraint, accs []simulation.Account) (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 RandomSimAccountWithKDenoms ¶
func RandomSimAccountWithKDenoms(ctx sdk.Context, r *rand.Rand, accs []simulation.Account, k int, bk BankKeeper) (simulation.Account, bool)
RandomSimAccountWithKDenoms returns an account that possesses k unique denoms.
func RandomSimAccountWithMinCoins ¶
func RandomSimAccountWithMinCoins(ctx sdk.Context, r *rand.Rand, accs []simulation.Account, coins sdk.Coins, bk BankKeeper) (simulation.Account, error)
func SelAddrWithDenom ¶
func SelAddrWithDenom(ctx sdk.Context, r *rand.Rand, accs []simulation.Account, denom string, bk BankKeeper) (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 SelAddrWithDenoms ¶
func SelAddrWithDenoms(ctx sdk.Context, r *rand.Rand, accs []simulation.Account, denoms []string, bk BankKeeper) (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.
Types ¶
type AccountKeeper ¶
type AccountKeeper interface { GetModuleAddress(name string) sdk.AccAddress HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 SetModuleAccount(sdk.Context, types.ModuleAccountI) GetModuleAccount(ctx sdk.Context, moduleName string) types.ModuleAccountI }
AccountKeeper defines the contract required for account APIs.
type BankKeeper ¶
type BankKeeper interface { GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error MintCoins(ctx sdk.Context, name string, amt sdk.Coins) error BurnCoins(ctx sdk.Context, name string, amt sdk.Coins) error SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins }
BankKeeper defines the contract needed to be fulfilled for banking and supply dependencies.
type DistrKeeper ¶
type DistrKeeper interface {
FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error
}
DistrKeeper defines the contract needed to be fulfilled for distribution keeper.
type SimAccountConstraint ¶
type SimAccountConstraint = func(account simulation.Account) bool