MCPcopy Create free account
hub / github.com/akash-network/node / SetupSimulation

Function SetupSimulation

app/sim/sim_utils.go:23–49  ·  view source on GitHub ↗

SetupSimulation creates the config, db (levelDB), temporary directory and logger for the simulation tests. If `FlagEnabledValue` is false, it skips the current test. Returns error on an invalid db instance or temp dir creation.

(dirPrefix, dbName string)

Source from the content-addressed store, hash-verified

21// the simulation tests. If `FlagEnabledValue` is false, it skips the current test.
22// Returns error on an invalid db instance or temp dir creation.
23func SetupSimulation(dirPrefix, dbName string) (simtypes.Config, dbm.DB, string, log.Logger, bool, error) {
24 if !FlagEnabledValue {
25 return simtypes.Config{}, nil, "", nil, true, nil
26 }
27
28 config := NewConfigFromFlags()
29 config.ChainID = "akash-sim"
30
31 var logger log.Logger
32 if FlagVerboseValue {
33 logger = log.NewTestLogger(&testing.T{})
34 } else {
35 logger = log.NewNopLogger()
36 }
37
38 dir, err := os.MkdirTemp("", dirPrefix)
39 if err != nil {
40 return simtypes.Config{}, nil, "", nil, false, err
41 }
42
43 db, err := dbm.NewDB(dbName, dbm.BackendType(config.DBBackend), dir)
44 if err != nil {
45 return simtypes.Config{}, nil, "", nil, false, err
46 }
47
48 return config, db, dir, logger, false, nil
49}
50
51// SimulationOperations retrieves the simulation params from the provided file path
52// and returns all the modules weighted operations

Callers 2

TestFullAppSimulationFunction · 0.92

Calls 1

NewConfigFromFlagsFunction · 0.85

Tested by 2

TestFullAppSimulationFunction · 0.74