Skip to content

Commit

Permalink
Add missing test database close calls
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Jan 9, 2023
1 parent 573d0e9 commit 948fac0
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
4 changes: 4 additions & 0 deletions dot/node_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ func TestInitNode_Integration(t *testing.T) {
})
require.NoError(t, err)
require.NotNil(t, db)
err = db.Close()
require.NoError(t, err)
}

func TestInitNode_GenesisSpec(t *testing.T) {
Expand All @@ -233,6 +235,8 @@ func TestInitNode_GenesisSpec(t *testing.T) {
})
require.NoError(t, err)
require.NotNil(t, db)
err = db.Close()
require.NoError(t, err)
}

func TestNodeInitializedIntegration(t *testing.T) {
Expand Down
4 changes: 4 additions & 0 deletions dot/state/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ func TestGetStorageChildAndGetStorageFromChild(t *testing.T) {
DataDir: filepath.Join(basepath, "db"),
})
require.NoError(t, err)
t.Cleanup(func() {
err = db.Close()
require.NoError(t, err)
})

_, genTrie, genHeader := newTestGenesisWithTrieAndHeader(t)

Expand Down
4 changes: 4 additions & 0 deletions lib/babe/verify_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,10 @@ func TestVerifyForkBlocksWithRespectiveEpochData(t *testing.T) {
InMemory: true,
})
require.NoError(t, err)
t.Cleanup(func() {
err := inMemoryDB.Close()
require.NoError(t, err)
})

const epochPrefix = "epoch"
epochStateDatabase := chaindb.NewTable(inMemoryDB, epochPrefix)
Expand Down
6 changes: 1 addition & 5 deletions lib/runtime/wasmer/imports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"testing"
"time"

"github.com/ChainSafe/chaindb"
"github.com/ChainSafe/gossamer/lib/common"
"github.com/ChainSafe/gossamer/lib/common/types"
"github.com/ChainSafe/gossamer/lib/crypto"
Expand Down Expand Up @@ -1793,10 +1792,7 @@ func Test_ext_trie_blake2_256_root_version_1(t *testing.T) {
func Test_ext_trie_blake2_256_verify_proof_version_1(t *testing.T) {
t.Parallel()

memdb, err := chaindb.NewBadgerDB(&chaindb.Config{
InMemory: true,
})
require.NoError(t, err)
memdb := newDatabase(t)

otherTrie := trie.NewEmptyTrie()
otherTrie.Put([]byte("simple"), []byte("cat"))
Expand Down
4 changes: 4 additions & 0 deletions lib/trie/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ func newTestDB(t *testing.T) chaindb.Database {
}
database, err := chaindb.NewBadgerDB(chainDBConfig)
require.NoError(t, err)
t.Cleanup(func() {
err := database.Close()
require.NoError(t, err)
})
return chaindb.NewTable(database, "trie")
}

Expand Down
5 changes: 5 additions & 0 deletions lib/trie/proof/proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ func Test_Generate_Verify(t *testing.T) {
InMemory: true,
})
require.NoError(t, err)
t.Cleanup(func() {
err := database.Close()
require.NoError(t, err)
})

err = trie.WriteDirty(database)
require.NoError(t, err)

Expand Down

0 comments on commit 948fac0

Please sign in to comment.