simulation

package
v0.24.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertAllInvariants

func AssertAllInvariants(t *testing.T, app *baseapp.BaseApp, tests []Invariant, log string)

AssertAllInvariants asserts a list of provided invariants against application state

func DisplayEvents

func DisplayEvents(events map[string]uint)

Pretty-print events as a table

func RandStringOfLength

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

Generate a random string of a particular length

func RandomAmount

func RandomAmount(r *rand.Rand, max sdk.Int) sdk.Int

Generate a random amount

func RandomKey

func RandomKey(r *rand.Rand, keys []crypto.PrivKey) crypto.PrivKey

Pick a random key from an array

func Simulate

func Simulate(
	t *testing.T, app *baseapp.BaseApp, appStateFn func(r *rand.Rand, accs []sdk.AccAddress) json.RawMessage, ops []TestAndRunTx, setups []RandSetup,
	invariants []Invariant, numKeys int, numBlocks int, blockSize int,
)

Simulate tests application by sending random messages.

func SimulateFromSeed

func SimulateFromSeed(
	t *testing.T, app *baseapp.BaseApp, appStateFn func(r *rand.Rand, accs []sdk.AccAddress) json.RawMessage, seed int64, ops []TestAndRunTx, setups []RandSetup,
	invariants []Invariant, numKeys int, numBlocks int, blockSize int,
)

SimulateFromSeed tests an application by running the provided operations, testing the provided invariants, but using the provided seed.

Types

type Invariant

type Invariant func(t *testing.T, app *baseapp.BaseApp, log string)

An Invariant is a function which tests a particular invariant. If the invariant has been broken, the function should halt the test and output the log.

func PeriodicInvariant

func PeriodicInvariant(invariant Invariant, period int, offset int) Invariant

PeriodicInvariant returns an Invariant function closure that asserts a given invariant if the mock application's last block modulo the given period is congruent to the given offset.

type RandSetup

type RandSetup func(r *rand.Rand, privKeys []crypto.PrivKey)

RandSetup performs the random setup the mock module needs.

type TestAndRunTx

type TestAndRunTx func(
	t *testing.T, r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context,
	privKeys []crypto.PrivKey, log string, event func(string),
) (action string, err sdk.Error)

TestAndRunTx produces a fuzzed transaction, and ensures the state transition was as expected. It returns a descriptive message "action" about what this fuzzed tx actually did, for ease of debugging.

Jump to

Keyboard shortcuts

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