Documentation ¶
Index ¶
- func AssertAllInvariants(t *testing.T, app *baseapp.BaseApp, tests []Invariant, log string)
- func DisplayEvents(events map[string]uint)
- func GetMemberOfInitialState(r *rand.Rand, weights []int) int
- func RandStringOfLength(r *rand.Rand, n int) string
- func RandomAmount(r *rand.Rand, max sdk.Int) sdk.Int
- func RandomKey(r *rand.Rand, keys []crypto.PrivKey) crypto.PrivKey
- func RandomRequestBeginBlock(t *testing.T, r *rand.Rand, validators map[string]mockValidator, ...) abci.RequestBeginBlock
- func Simulate(t *testing.T, app *baseapp.BaseApp, ...)
- func SimulateFromSeed(t *testing.T, app *baseapp.BaseApp, ...)
- type Invariant
- type RandSetup
- type TestAndRunTx
- type TransitionMatrix
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertAllInvariants ¶
AssertAllInvariants asserts a list of provided invariants against application state
func GetMemberOfInitialState ¶
GetMemberOfInitialState takes an initial array of weights, of size n. It returns a weighted random number in [0,n).
func RandStringOfLength ¶
Generate a random string of a particular length
func RandomRequestBeginBlock ¶
func RandomRequestBeginBlock(t *testing.T, r *rand.Rand, validators map[string]mockValidator, livenessTransitions TransitionMatrix, evidenceFraction float64, pastTimes []time.Time, event func(string), header abci.Header, log string) abci.RequestBeginBlock
RandomRequestBeginBlock generates a list of signing validators according to the provided list of validators, signing fraction, and evidence fraction
func Simulate ¶
func Simulate( t *testing.T, app *baseapp.BaseApp, appStateFn func(r *rand.Rand, keys []crypto.PrivKey, accs []sdk.AccAddress) json.RawMessage, ops []TestAndRunTx, setups []RandSetup, invariants []Invariant, numBlocks int, blockSize int, commit bool, )
Simulate tests application by sending random messages.
func SimulateFromSeed ¶
func SimulateFromSeed( t *testing.T, app *baseapp.BaseApp, appStateFn func(r *rand.Rand, keys []crypto.PrivKey, accs []sdk.AccAddress) json.RawMessage, seed int64, ops []TestAndRunTx, setups []RandSetup, invariants []Invariant, numBlocks int, blockSize int, commit bool, )
SimulateFromSeed tests an application by running the provided operations, testing the provided invariants, but using the provided seed.
Types ¶
type Invariant ¶
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.
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.
type TransitionMatrix ¶
type TransitionMatrix struct {
// contains filtered or unexported fields
}
TransitionMatrix is _almost_ a left stochastic matrix. It is technically not one due to not normalizing the column values. In the future, if we want to find the steady state distribution, it will be quite easy to normalize these values to get a stochastic matrix. Floats aren't currently used as the default due to non-determinism across architectures
func CreateTransitionMatrix ¶
func CreateTransitionMatrix(weights [][]int) (TransitionMatrix, error)
CreateTransitionMatrix creates a transition matrix from the provided weights. TODO: Provide example usage