Skip to content

Commit

Permalink
Go 1.13 backport
Browse files Browse the repository at this point in the history
  • Loading branch information
alpe committed Jun 29, 2020
1 parent f71a9bb commit 005c8bf
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions x/wasm/internal/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import (
)

func TestGenesisExportImport(t *testing.T) {
srcKeeper, srcCtx := setupKeeper(t)
srcKeeper, srcCtx, srcCleanup := setupKeeper(t)
defer srcCleanup()
wasmCode, err := ioutil.ReadFile("./testdata/contract.wasm")
require.NoError(t, err)

Expand Down Expand Up @@ -48,7 +49,8 @@ func TestGenesisExportImport(t *testing.T) {
genesisState := ExportGenesis(srcCtx, srcKeeper)

// re-import
dstKeeper, dstCtx := setupKeeper(t)
dstKeeper, dstCtx, dstCleanup := setupKeeper(t)
defer dstCleanup()
InitGenesis(dstCtx, dstKeeper, genesisState)

// compare whole DB
Expand All @@ -65,10 +67,11 @@ func TestGenesisExportImport(t *testing.T) {
require.False(t, dstIT.Valid())
}

func setupKeeper(t *testing.T) (Keeper, sdk.Context) {
func setupKeeper(t *testing.T) (Keeper, sdk.Context, func()) {
tempDir, err := ioutil.TempDir("", "wasm")
require.NoError(t, err)
t.Cleanup(func() { os.RemoveAll(tempDir) })
cleanup := func() { os.RemoveAll(tempDir) }
//t.Cleanup(cleanup) todo: add with Go 1.14

keyContract := sdk.NewKVStoreKey(wasmTypes.StoreKey)
db := dbm.NewMemDB()
Expand All @@ -85,5 +88,5 @@ func setupKeeper(t *testing.T) (Keeper, sdk.Context) {
wasmConfig := wasmTypes.DefaultWasmConfig()

srcKeeper := NewKeeper(cdc, keyContract, auth.AccountKeeper{}, nil, staking.Keeper{}, nil, tempDir, wasmConfig, "", nil, nil)
return srcKeeper, ctx
return srcKeeper, ctx, cleanup
}

0 comments on commit 005c8bf

Please sign in to comment.