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

Function TestAppSimulationAfterImport

app/sim_test.go:388–459  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

386}
387
388func TestAppSimulationAfterImport(t *testing.T) {
389 config, db, dir, logger, skip, err := sim.SetupSimulation("leveldb-app-sim", "Simulation")
390 if skip {
391 t.Skip("skipping application simulation after import")
392 }
393
394 require.NoError(t, err, "simulation setup failed")
395
396 defer func() {
397 _ = db.Close()
398 require.NoError(t, os.RemoveAll(dir))
399 }()
400
401 encodingConfig := sdkutil.MakeEncodingConfig()
402 akash.ModuleBasics().RegisterInterfaces(encodingConfig.InterfaceRegistry)
403
404 appOpts := viper.New()
405 appOpts.Set("home", t.TempDir()) // ensure a unique folder per run
406
407 r := rand.New(rand.NewSource(config.Seed)) // nolint: gosec
408 genTime := sdksim.RandTimestamp(r)
409
410 appOpts.Set("GenesisTime", genTime)
411
412 app := akash.NewApp(logger, db, nil, true, sim.FlagPeriodValue, map[int64]bool{}, encodingConfig, appOpts, fauxMerkleModeOpt, baseapp.SetChainID(AppChainID))
413 require.Equal(t, akash.AppName, app.Name())
414
415 // Run randomized simulation
416 stopEarly, simParams, simErr := simulateFromSeedFunc(t, app, config)
417
418 // export state and simParams before the simulation error is checked
419 err = simtestutil.CheckExportSimulation(app, config, simParams)
420 require.NoError(t, err)
421 require.NoError(t, simErr)
422
423 if config.Commit {
424 sim.PrintStats(db)
425 }
426
427 if stopEarly {
428 fmt.Println("can't export or import a zero-validator genesis, exiting test...")
429 return
430 }
431
432 fmt.Printf("exporting genesis...\n")
433
434 exported, err := app.ExportAppStateAndValidators(true, []string{}, []string{})
435 require.NoError(t, err)
436
437 fmt.Printf("importing genesis...\n")
438
439 _, newDB, newDir, _, val, err := sim.SetupSimulation("leveldb-app-sim-2", "Simulation-2")
440 require.NoError(t, err, "simulation setup failed", val)
441
442 defer func() {
443 _ = newDB.Close()
444 require.NoError(t, os.RemoveAll(newDir))
445 }()

Callers

nothing calls this directly

Calls 8

SetupSimulationFunction · 0.92
PrintStatsFunction · 0.92
simulateFromSeedFuncFunction · 0.85
InitChainMethod · 0.80
CloseMethod · 0.65
NameMethod · 0.65
RegisterInterfacesMethod · 0.45

Tested by

no test coverage detected