Skip to content

Commit

Permalink
ffldb: add check for deleting files that are open
Browse files Browse the repository at this point in the history
This check let's us ensure that attempting to delete open files are
caught during unit tests.
  • Loading branch information
kcalvinalvin committed Jul 1, 2024
1 parent 4712e20 commit 8b5f2aa
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions database/ffldb/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,20 @@ func TestPrune(t *testing.T) {
t.Fatal(err)
}

// Open the first block file before the pruning happens in the
// code snippet below. This let's us test that block files are
// properly closed before attempting to delete them.
err = db.View(func(tx database.Tx) error {
_, err := tx.FetchBlock(blocks[0].Hash())
if err != nil {
return err
}
return nil
})
if err != nil {
t.Fatal(err)
}

var deletedBlocks []chainhash.Hash

// This should leave 3 files on disk.
Expand Down

0 comments on commit 8b5f2aa

Please sign in to comment.