Skip to content

Commit

Permalink
fixup! [WIP] leaking DB snapshot - bc has to be closed
Browse files Browse the repository at this point in the history
  • Loading branch information
pnowosie committed Aug 14, 2024
1 parent 806f194 commit dcc6f22
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions migration/migration_pkg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func TestRelocateContractStorageRootKeys(t *testing.T) {
func TestRecalculateBloomFilters(t *testing.T) {
testdb := pebble.NewMemTest(t)
chain := blockchain.New(testdb, &utils.Mainnet)
defer chain.Close()
client := feeder.NewTestClient(t, &utils.Mainnet)
gw := adaptfeeder.New(client)

Expand Down Expand Up @@ -165,6 +166,7 @@ func TestChangeTrieNodeEncoding(t *testing.T) {
func TestCalculateBlockCommitments(t *testing.T) {
testdb := pebble.NewMemTest(t)
chain := blockchain.New(testdb, &utils.Mainnet)
defer chain.Close()
client := feeder.NewTestClient(t, &utils.Mainnet)
gw := adaptfeeder.New(client)

Expand Down
1 change: 1 addition & 0 deletions node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func TestNetworkVerificationOnNonEmptyDB(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 250*time.Millisecond)
require.NoError(t, syncer.Run(ctx))
cancel()
chain.Close()
require.NoError(t, database.Close())

_, err = node.New(&node.Config{
Expand Down
1 change: 1 addition & 0 deletions rpc/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func TestEvents(t *testing.T) {
testDB := pebble.NewMemTest(t)
n := utils.Ptr(utils.Sepolia)
chain := blockchain.New(testDB, n)
defer chain.Close()

client := feeder.NewTestClient(t, n)
gw := adaptfeeder.New(client)
Expand Down
5 changes: 5 additions & 0 deletions sync/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func TestSyncBlocks(t *testing.T) {
assert.Equal(t, b, block)
height--
}
bc.Close()
return nil
}())
}
Expand Down Expand Up @@ -147,6 +148,7 @@ func TestReorg(t *testing.T) {

// sync to integration for 2 blocks
bc := blockchain.New(testDB, &utils.Integration)
defer bc.Close()
synchronizer := sync.New(bc, integGw, utils.NewNopZapLogger(), 0, false)

ctx, cancel := context.WithTimeout(context.Background(), timeout)
Expand All @@ -155,6 +157,7 @@ func TestReorg(t *testing.T) {

t.Run("resync to mainnet with the same db", func(t *testing.T) {
bc := blockchain.New(testDB, &utils.Mainnet)
defer bc.Close()

// Ensure current head is Integration head
head, err := bc.HeadsHeader()
Expand Down Expand Up @@ -182,6 +185,7 @@ func TestPending(t *testing.T) {
testDB := pebble.NewMemTest(t)
log := utils.NewNopZapLogger()
bc := blockchain.New(testDB, &utils.Mainnet)
defer bc.Close()
synchronizer := sync.New(bc, gw, log, time.Millisecond*100, false)
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)

Expand All @@ -201,6 +205,7 @@ func TestSubscribeNewHeads(t *testing.T) {
log := utils.NewNopZapLogger()
integration := utils.Integration
chain := blockchain.New(testDB, &integration)
defer chain.Close()
integrationClient := feeder.NewTestClient(t, &integration)
gw := adaptfeeder.New(integrationClient)
syncer := sync.New(chain, gw, log, 0, false)
Expand Down

0 comments on commit dcc6f22

Please sign in to comment.