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