channeldb: ensure the cleanUp func is always run during tests
This commit is contained in:
parent
326c62c6b5
commit
587bde5636
@ -98,8 +98,8 @@ func makeTestDB() (*DB, func(), error) {
|
||||
}
|
||||
|
||||
cleanUp := func() {
|
||||
os.RemoveAll(tempDirName)
|
||||
cdb.Close()
|
||||
os.RemoveAll(tempDirName)
|
||||
}
|
||||
|
||||
return cdb, cleanUp, nil
|
||||
@ -172,10 +172,10 @@ func createTestChannelState(cdb *DB) (*OpenChannel, error) {
|
||||
|
||||
func TestOpenChannelPutGetDelete(t *testing.T) {
|
||||
cdb, cleanUp, err := makeTestDB()
|
||||
if err != nil {
|
||||
t.Fatalf("uanble to make test database: %v", err)
|
||||
}
|
||||
defer cleanUp()
|
||||
if err != nil {
|
||||
t.Fatalf("unable to make test database: %v", err)
|
||||
}
|
||||
|
||||
// Create the test channel state, then add an additional fake HTLC
|
||||
// before syncing to disk.
|
||||
@ -362,10 +362,10 @@ func TestOpenChannelPutGetDelete(t *testing.T) {
|
||||
|
||||
func TestChannelStateTransition(t *testing.T) {
|
||||
cdb, cleanUp, err := makeTestDB()
|
||||
defer cleanUp()
|
||||
if err != nil {
|
||||
t.Fatalf("unable to make test database: %v", err)
|
||||
}
|
||||
defer cleanUp()
|
||||
|
||||
// First create a minimal channel, then perform a full sync in order to
|
||||
// persist the data.
|
||||
|
@ -42,10 +42,10 @@ func createTestVertex(db *DB) (*LightningNode, error) {
|
||||
|
||||
func TestNodeInsertionAndDeletion(t *testing.T) {
|
||||
db, cleanUp, err := makeTestDB()
|
||||
defer cleanUp()
|
||||
if err != nil {
|
||||
t.Fatalf("unable to make test database: %v", err)
|
||||
}
|
||||
defer cleanUp()
|
||||
|
||||
graph := db.ChannelGraph()
|
||||
|
||||
@ -96,10 +96,10 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
||||
|
||||
func TestAliasLookup(t *testing.T) {
|
||||
db, cleanUp, err := makeTestDB()
|
||||
defer cleanUp()
|
||||
if err != nil {
|
||||
t.Fatalf("unable to make test database: %v", err)
|
||||
}
|
||||
defer cleanUp()
|
||||
|
||||
graph := db.ChannelGraph()
|
||||
|
||||
@ -140,10 +140,10 @@ func TestAliasLookup(t *testing.T) {
|
||||
|
||||
func TestSourceNode(t *testing.T) {
|
||||
db, cleanUp, err := makeTestDB()
|
||||
defer cleanUp()
|
||||
if err != nil {
|
||||
t.Fatalf("unable to make test database: %v", err)
|
||||
}
|
||||
defer cleanUp()
|
||||
|
||||
graph := db.ChannelGraph()
|
||||
|
||||
@ -180,10 +180,10 @@ func TestSourceNode(t *testing.T) {
|
||||
|
||||
func TestEdgeInsertionDeletion(t *testing.T) {
|
||||
db, cleanUp, err := makeTestDB()
|
||||
defer cleanUp()
|
||||
if err != nil {
|
||||
t.Fatalf("unable to make test database: %v", err)
|
||||
}
|
||||
defer cleanUp()
|
||||
|
||||
graph := db.ChannelGraph()
|
||||
|
||||
@ -238,10 +238,10 @@ func TestEdgeInsertionDeletion(t *testing.T) {
|
||||
|
||||
func TestEdgeInfoUpdates(t *testing.T) {
|
||||
db, cleanUp, err := makeTestDB()
|
||||
defer cleanUp()
|
||||
if err != nil {
|
||||
t.Fatalf("unable to make test database: %v", err)
|
||||
}
|
||||
defer cleanUp()
|
||||
|
||||
graph := db.ChannelGraph()
|
||||
|
||||
@ -378,10 +378,10 @@ func randEdge(chanID uint64, op wire.OutPoint, db *DB) *ChannelEdge {
|
||||
|
||||
func TestGraphTraversal(t *testing.T) {
|
||||
db, cleanUp, err := makeTestDB()
|
||||
defer cleanUp()
|
||||
if err != nil {
|
||||
t.Fatalf("unable to make test database: %v", err)
|
||||
}
|
||||
defer cleanUp()
|
||||
|
||||
graph := db.ChannelGraph()
|
||||
|
||||
@ -544,10 +544,10 @@ func asserNumChans(t *testing.T, graph *ChannelGraph, n int) {
|
||||
|
||||
func TestGraphPruning(t *testing.T) {
|
||||
db, cleanUp, err := makeTestDB()
|
||||
defer cleanUp()
|
||||
if err != nil {
|
||||
t.Fatalf("unable to make test database: %v", err)
|
||||
}
|
||||
defer cleanUp()
|
||||
|
||||
graph := db.ChannelGraph()
|
||||
|
||||
|
@ -33,10 +33,10 @@ func randInvoice(value btcutil.Amount) (*Invoice, error) {
|
||||
|
||||
func TestInvoiceWorkflow(t *testing.T) {
|
||||
db, cleanUp, err := makeTestDB()
|
||||
defer cleanUp()
|
||||
if err != nil {
|
||||
t.Fatalf("unable to make test db: %v", err)
|
||||
}
|
||||
defer cleanUp()
|
||||
|
||||
// Create a fake invoice which we'll use several times in the tests
|
||||
// below.
|
||||
|
@ -13,10 +13,10 @@ import (
|
||||
// database.
|
||||
func TestVersionFetchPut(t *testing.T) {
|
||||
db, cleanUp, err := makeTestDB()
|
||||
defer cleanUp()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer cleanUp()
|
||||
|
||||
meta, err := db.FetchMeta(nil)
|
||||
if err != nil {
|
||||
@ -117,10 +117,10 @@ func applyMigration(t *testing.T, beforeMigration, afterMigration func(d *DB),
|
||||
migrationFunc migration, shouldFail bool) {
|
||||
|
||||
cdb, cleanUp, err := makeTestDB()
|
||||
defer cleanUp()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer cleanUp()
|
||||
|
||||
// beforeMigration usually used for populating the database
|
||||
// with test data.
|
||||
|
Loading…
Reference in New Issue
Block a user