perf: Replace runsim with Go stdlib testing (#24045)
Co-authored-by: Alex | Interchain Labs <alex@interchainlabs.io>
This commit is contained in:
co-authored by
Alex | Interchain Labs
parent
b7c35f2568
commit
bc57ce3ba7
@@ -2,6 +2,7 @@ package cli
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
)
|
||||
@@ -22,15 +23,21 @@ var (
|
||||
FlagBlockSizeValue int
|
||||
FlagLeanValue bool
|
||||
FlagCommitValue bool
|
||||
FlagOnOperationValue bool // TODO: Remove in favor of binary search for invariant violation
|
||||
FlagAllInvariantsValue bool
|
||||
FlagDBBackendValue string
|
||||
|
||||
FlagEnabledValue bool
|
||||
FlagVerboseValue bool
|
||||
FlagPeriodValue uint
|
||||
FlagGenesisTimeValue int64
|
||||
FlagSigverifyTxValue bool
|
||||
FlagFauxMerkle bool
|
||||
|
||||
// Deprecated: This flag is unused and will be removed in a future release.
|
||||
FlagPeriodValue uint
|
||||
// Deprecated: This flag is unused and will be removed in a future release.
|
||||
FlagEnabledValue bool
|
||||
// Deprecated: This flag is unused and will be removed in a future release.
|
||||
FlagOnOperationValue bool
|
||||
// Deprecated: This flag is unused and will be removed in a future release.
|
||||
FlagAllInvariantsValue bool
|
||||
)
|
||||
|
||||
// GetSimulatorFlags gets the values of all the available simulation flags
|
||||
@@ -47,17 +54,19 @@ func GetSimulatorFlags() {
|
||||
flag.IntVar(&FlagNumBlocksValue, "NumBlocks", 500, "number of new blocks to simulate from the initial block height")
|
||||
flag.IntVar(&FlagBlockSizeValue, "BlockSize", 200, "operations per block")
|
||||
flag.BoolVar(&FlagLeanValue, "Lean", false, "lean simulation log output")
|
||||
flag.BoolVar(&FlagCommitValue, "Commit", false, "have the simulation commit")
|
||||
flag.BoolVar(&FlagOnOperationValue, "SimulateEveryOperation", false, "run slow invariants every operation")
|
||||
flag.BoolVar(&FlagAllInvariantsValue, "PrintAllInvariants", false, "print all invariants if a broken invariant is found")
|
||||
flag.StringVar(&FlagDBBackendValue, "DBBackend", "goleveldb", "custom db backend type")
|
||||
flag.BoolVar(&FlagCommitValue, "Commit", true, "have the simulation commit")
|
||||
flag.StringVar(&FlagDBBackendValue, "DBBackend", "memdb", "custom db backend type: goleveldb, pebbledb, memdb")
|
||||
|
||||
// simulation flags
|
||||
flag.BoolVar(&FlagEnabledValue, "Enabled", false, "enable the simulation")
|
||||
flag.BoolVar(&FlagVerboseValue, "Verbose", false, "verbose log output")
|
||||
flag.UintVar(&FlagPeriodValue, "Period", 0, "run slow invariants only once every period assertions")
|
||||
flag.Int64Var(&FlagGenesisTimeValue, "GenesisTime", 0, "override genesis UNIX time instead of using a random UNIX time")
|
||||
flag.Int64Var(&FlagGenesisTimeValue, "GenesisTime", time.Now().Unix(), "use current time as genesis UNIX time for default")
|
||||
flag.BoolVar(&FlagSigverifyTxValue, "SigverifyTx", true, "whether to sigverify check for transaction ")
|
||||
flag.BoolVar(&FlagFauxMerkle, "FauxMerkle", false, "use faux merkle instead of iavl")
|
||||
|
||||
flag.UintVar(&FlagPeriodValue, "Period", 0, "This parameter is unused and will be removed")
|
||||
flag.BoolVar(&FlagEnabledValue, "Enabled", false, "This parameter is unused and will be removed")
|
||||
flag.BoolVar(&FlagOnOperationValue, "SimulateEveryOperation", false, "This parameter is unused and will be removed")
|
||||
flag.BoolVar(&FlagAllInvariantsValue, "PrintAllInvariants", false, "This parameter is unused and will be removed")
|
||||
}
|
||||
|
||||
// NewConfigFromFlags creates a simulation from the retrieved values of the flags.
|
||||
@@ -71,12 +80,28 @@ func NewConfigFromFlags() simulation.Config {
|
||||
ExportStatsPath: FlagExportStatsPathValue,
|
||||
Seed: FlagSeedValue,
|
||||
InitialBlockHeight: FlagInitialBlockHeightValue,
|
||||
GenesisTime: FlagGenesisTimeValue,
|
||||
NumBlocks: FlagNumBlocksValue,
|
||||
BlockSize: FlagBlockSizeValue,
|
||||
Lean: FlagLeanValue,
|
||||
Commit: FlagCommitValue,
|
||||
OnOperation: FlagOnOperationValue,
|
||||
AllInvariants: FlagAllInvariantsValue,
|
||||
DBBackend: FlagDBBackendValue,
|
||||
}
|
||||
}
|
||||
|
||||
// GetDeprecatedFlagUsed return list of deprecated flag names that are being used.
|
||||
// This function is for internal usage only and may be removed with the deprecated fields.
|
||||
func GetDeprecatedFlagUsed() []string {
|
||||
var usedFlags []string
|
||||
for _, flagName := range []string{
|
||||
"Enabled",
|
||||
"SimulateEveryOperation",
|
||||
"PrintAllInvariants",
|
||||
"Period",
|
||||
} {
|
||||
if flag.Lookup(flagName) != nil {
|
||||
usedFlags = append(usedFlags, flagName)
|
||||
}
|
||||
}
|
||||
return usedFlags
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user