Skip to content

Commit

Permalink
test: use temporary folder in tests (backport #14246) (#14250)
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed Dec 11, 2022
1 parent c51f86c commit c98cde9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions simapp/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestSimAppExportAndBlockedAddrs(t *testing.T) {
app := NewSimappWithCustomOptions(t, false, SetupOptions{
Logger: logger,
DB: db,
AppOpts: simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome),
AppOpts: simtestutil.NewAppOptionsWithFlagHome(t.TempDir()),
})

// BlockedAddresses returns a map of addresses in app v1 and a map of modules name in app v2.
Expand All @@ -67,15 +67,15 @@ func TestSimAppExportAndBlockedAddrs(t *testing.T) {

logger2 := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
// Making a new app object with the db, so that initchain hasn't been called
app2 := NewSimApp(logger2, db, nil, true, simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome))
app2 := NewSimApp(logger2, db, nil, true, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()))
_, err := app2.ExportAppStateAndValidators(false, []string{}, []string{})
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
}

func TestRunMigrations(t *testing.T) {
db := dbm.NewMemDB()
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
app := NewSimApp(logger, db, nil, true, simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome))
app := NewSimApp(logger, db, nil, true, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()))

// Create a new baseapp and configurator for the purpose of this test.
bApp := baseapp.NewBaseApp(app.Name(), logger, db, app.TxConfig().TxDecoder())
Expand Down Expand Up @@ -209,7 +209,7 @@ func TestRunMigrations(t *testing.T) {
func TestInitGenesisOnMigration(t *testing.T) {
db := dbm.NewMemDB()
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
app := NewSimApp(logger, db, nil, true, simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome))
app := NewSimApp(logger, db, nil, true, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()))
ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})

// Create a mock module. This module will serve as the new module we're
Expand Down Expand Up @@ -255,7 +255,7 @@ func TestUpgradeStateOnGenesis(t *testing.T) {
app := NewSimappWithCustomOptions(t, false, SetupOptions{
Logger: logger,
DB: db,
AppOpts: simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome),
AppOpts: simtestutil.NewAppOptionsWithFlagHome(t.TempDir()),
})

// make sure the upgrade keeper has version map in state
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/store/rootmulti/rollback_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestRollback(t *testing.T) {
options := simapp.SetupOptions{
Logger: log.NewNopLogger(),
DB: db,
AppOpts: simtestutil.NewAppOptionsWithFlagHome(simapp.DefaultNodeHome),
AppOpts: simtestutil.NewAppOptionsWithFlagHome(t.TempDir()),
}
app := simapp.NewSimappWithCustomOptions(t, false, options)
app.Commit()
Expand Down Expand Up @@ -46,7 +46,7 @@ func TestRollback(t *testing.T) {
require.Equal(t, target, app.LastBlockHeight())

// recreate app to have clean check state
app = simapp.NewSimApp(options.Logger, options.DB, nil, true, simtestutil.NewAppOptionsWithFlagHome(simapp.DefaultNodeHome))
app = simapp.NewSimApp(options.Logger, options.DB, nil, true, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()))
store = app.NewContext(true, tmproto.Header{}).KVStore(app.GetKey("bank"))
require.Equal(t, []byte("value5"), store.Get([]byte("key")))

Expand Down

0 comments on commit c98cde9

Please sign in to comment.