sample

package
v0.0.0-...-3e49bf5 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 15 Imported by: 4

Documentation

Overview

Package sample provides methods to initialize sample object of various types for test purposes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccAddress

func AccAddress(r *rand.Rand) sdk.AccAddress

AccAddress returns a sample account address

func Address

func Address(r *rand.Rand) string

Address returns a sample string account address

func AlphaString

func AlphaString(r *rand.Rand, n int) string

AlphaString returns a random string with lowercase alpha char of length n

func Bool

func Bool(r *rand.Rand) bool

Bool returns randomly true or false

func Bytes

func Bytes(r *rand.Rand, n int) []byte

Bytes returns a random array of bytes

func Codec

func Codec(registries ...ExtraRegistries) codec.Codec

Codec returns a codec with preregistered interfaces

func Coin

func Coin(r *rand.Rand) sdk.Coin

Coin returns a sample coin structure

func CoinWithRange

func CoinWithRange(r *rand.Rand, min, max int64) sdk.Coin

CoinWithRange returns a sample coin structure where the amount is a random number between provided min and max values with a random denom

func CoinWithRangeAmount

func CoinWithRangeAmount(r *rand.Rand, denom string, min, max int64) sdk.Coin

CoinWithRangeAmount returns a sample coin structure where the amount is a random number between provided min and max values with a given denom

func Coins

func Coins(r *rand.Rand) sdk.Coins

Coins returns a sample coins structure

func CoinsWithRange

func CoinsWithRange(r *rand.Rand, min, max int64) sdk.Coins

CoinsWithRange returns a sample coins structure where the amount is a random number between provided min and max values

func CoinsWithRangeAmount

func CoinsWithRangeAmount(r *rand.Rand, denom1, denom2, denom3 string, min, max int64) sdk.Coins

CoinsWithRangeAmount returns a sample coins structure where the amount is a random number between provided min and max values with a set of given denoms

func ConsAddress

func ConsAddress(r *rand.Rand) sdk.ConsAddress

ConsAddress returns a sample consensus address

func Delegation

func Delegation(t testing.TB, r *rand.Rand, addr string) stakingtypes.Delegation

Delegation returns staking delegation with the given address

func Duration

func Duration(r *rand.Rand) time.Duration

Duration returns a sample time.Duration between a second and 21 days

func DurationFromRange

func DurationFromRange(r *rand.Rand, min, max time.Duration) time.Duration

DurationFromRange returns a sample time.Duration between the min and max values provided

func Int

func Int(r *rand.Rand) sdkmath.Int

Int returns a sample sdkmath.Int

func InterfaceRegistry

func InterfaceRegistry(registries ...ExtraRegistries) codectypes.InterfaceRegistry

func NonAlphaString

func NonAlphaString(r *rand.Rand, n int) string

NonAlphaString returns a random string with non alpha char of length n

func OperatorAddress

func OperatorAddress(r *rand.Rand) string

OperatorAddress returns a sample string validator operator address

func PubKey

func PubKey(r *rand.Rand) crypto.PubKey

PubKey returns a sample account PubKey

func Rand

func Rand() *rand.Rand

Rand returns a sample Rand object for randomness

func String

func String(r *rand.Rand, n int) string

String returns a random string of length n

func Time

func Time(r *rand.Rand) time.Time

Time returns a sample time

func Uint64

func Uint64(r *rand.Rand) uint64

Uint64 returns a random uint64

func ValAddress

func ValAddress(r *rand.Rand) sdk.ValAddress

ValAddress returns a sample validator operator address

func Validator

func Validator(t testing.TB, r *rand.Rand) stakingtypes.Validator

Validator returns a sample staking validator

func ZeroTime

func ZeroTime() time.Time

ZeroTime returns time.Time that represents 0

Types

type ExtraRegistries

type ExtraRegistries func(codectypes.InterfaceRegistry)

ExtraRegistries is a function passed to sample.InterfaceRegistry() where any added interface registries can be registered. To register all interfaces for your application pass app.ModuleBasics.RegisterInterfaces as the argument.

Jump to

Keyboard shortcuts

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