val comments
This commit is contained in:
parent
bbf574cedb
commit
bfc7944b55
|
@ -6,8 +6,7 @@ It is primarily intended for fuzz testing the integration of modules. It will
|
|||
test that the provided operations are interoperable, and that the desired
|
||||
invariants hold. It can additionally be used to detect what the performance
|
||||
benchmarks in the system are, by using benchmarking mode and cpu / mem
|
||||
profiling. If it detects a failure, it provides the entire log of what was
|
||||
ran,
|
||||
profiling. If it detects a failure, it provides the entire log of what was ran.
|
||||
|
||||
The simulator takes as input: a random seed, the set of operations to run, the
|
||||
invariants to test, and additional parameters to configure how long to run, and
|
||||
|
|
|
@ -44,29 +44,6 @@ type Params struct {
|
|||
BlockSizeTransitionMatrix TransitionMatrix
|
||||
}
|
||||
|
||||
// getBlockSize returns a block size as determined from the transition matrix.
|
||||
// It targets making average block size the provided parameter. The three
|
||||
// states it moves between are:
|
||||
// - "over stuffed" blocks with average size of 2 * avgblocksize,
|
||||
// - normal sized blocks, hitting avgBlocksize on average,
|
||||
// - and empty blocks, with no txs / only txs scheduled from the past.
|
||||
func getBlockSize(r *rand.Rand, params Params,
|
||||
lastBlockSizeState, avgBlockSize int) (state, blocksize int) {
|
||||
|
||||
// TODO: Make default blocksize transition matrix actually make the average
|
||||
// blocksize equal to avgBlockSize.
|
||||
state = params.BlockSizeTransitionMatrix.NextState(r, lastBlockSizeState)
|
||||
switch state {
|
||||
case 0:
|
||||
blocksize = r.Intn(avgBlockSize * 4)
|
||||
case 1:
|
||||
blocksize = r.Intn(avgBlockSize * 2)
|
||||
default:
|
||||
blocksize = 0
|
||||
}
|
||||
return state, blocksize
|
||||
}
|
||||
|
||||
// Return default simulation parameters
|
||||
func DefaultParams() Params {
|
||||
return Params{
|
||||
|
|
|
@ -51,7 +51,7 @@ func (t TransitionMatrix) NextState(r *rand.Rand, i int) int {
|
|||
}
|
||||
|
||||
// GetMemberOfInitialState takes an initial array of weights, of size n.
|
||||
// It returns a weighted random number in [0,n].
|
||||
// It returns a weighted random number in [0,n).
|
||||
func GetMemberOfInitialState(r *rand.Rand, weights []int) int {
|
||||
n := len(weights)
|
||||
total := 0
|
||||
|
|
|
@ -2,6 +2,7 @@ package simulation
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -78,3 +79,26 @@ func logPrinter(testingmode bool, logs []*strings.Builder) func() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// getBlockSize returns a block size as determined from the transition matrix.
|
||||
// It targets making average block size the provided parameter. The three
|
||||
// states it moves between are:
|
||||
// - "over stuffed" blocks with average size of 2 * avgblocksize,
|
||||
// - normal sized blocks, hitting avgBlocksize on average,
|
||||
// - and empty blocks, with no txs / only txs scheduled from the past.
|
||||
func getBlockSize(r *rand.Rand, params Params,
|
||||
lastBlockSizeState, avgBlockSize int) (state, blocksize int) {
|
||||
|
||||
// TODO: Make default blocksize transition matrix actually make the average
|
||||
// blocksize equal to avgBlockSize.
|
||||
state = params.BlockSizeTransitionMatrix.NextState(r, lastBlockSizeState)
|
||||
switch state {
|
||||
case 0:
|
||||
blocksize = r.Intn(avgBlockSize * 4)
|
||||
case 1:
|
||||
blocksize = r.Intn(avgBlockSize * 2)
|
||||
default:
|
||||
blocksize = 0
|
||||
}
|
||||
return state, blocksize
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue