(t *testing.T)
| 459 | } |
| 460 | |
| 461 | func TestAppStateDeterminism(t *testing.T) { |
| 462 | if !sim.FlagEnabledValue { |
| 463 | t.Skip("skipping application simulation") |
| 464 | } |
| 465 | |
| 466 | encodingConfig := sdkutil.MakeEncodingConfig() |
| 467 | akash.ModuleBasics().RegisterInterfaces(encodingConfig.InterfaceRegistry) |
| 468 | |
| 469 | config := sim.NewConfigFromFlags() |
| 470 | config.InitialBlockHeight = 1 |
| 471 | config.ExportParamsPath = "" |
| 472 | config.ChainID = AppChainID |
| 473 | config.GenesisTime = time.Now().UTC().Unix() |
| 474 | |
| 475 | numSeeds := 2 |
| 476 | numTimesToRunPerSeed := 3 |
| 477 | appHashList := make([]json.RawMessage, numTimesToRunPerSeed) |
| 478 | |
| 479 | for i := 0; i < numSeeds; i++ { |
| 480 | config.Seed = rand.Int63() // nolint:gosec |
| 481 | |
| 482 | for j := 0; j < numTimesToRunPerSeed; j++ { |
| 483 | var logger log.Logger |
| 484 | if sim.FlagVerboseValue { |
| 485 | logger = log.NewTestLogger(&testing.T{}) |
| 486 | } else { |
| 487 | logger = log.NewNopLogger() |
| 488 | } |
| 489 | |
| 490 | db := dbm.NewMemDB() |
| 491 | |
| 492 | appOpts := viper.New() |
| 493 | appOpts.Set("home", t.TempDir()) // ensure a unique folder per run |
| 494 | |
| 495 | r := rand.New(rand.NewSource(config.Seed)) // nolint: gosec |
| 496 | genTime := sdksim.RandTimestamp(r) |
| 497 | |
| 498 | appOpts.Set("GenesisTime", genTime) |
| 499 | |
| 500 | app := akash.NewApp(logger, db, nil, true, sim.FlagPeriodValue, map[int64]bool{}, encodingConfig, appOpts, interBlockCacheOpt(), baseapp.SetChainID(AppChainID)) |
| 501 | |
| 502 | fmt.Printf( |
| 503 | "running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n", |
| 504 | config.Seed, i+1, numSeeds, j+1, numTimesToRunPerSeed, |
| 505 | ) |
| 506 | |
| 507 | _, _, err := simulateFromSeedFunc(t, app, config) |
| 508 | require.NoError(t, err) |
| 509 | |
| 510 | if config.Commit { |
| 511 | sim.PrintStats(db) |
| 512 | } |
| 513 | |
| 514 | appHash := app.LastCommitID().Hash |
| 515 | appHashList[j] = appHash |
| 516 | |
| 517 | if j != 0 { |
| 518 | require.Equal( |
nothing calls this directly
no test coverage detected