From c357511051d23eb47befe2be0f563acdac39f971 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Fri, 21 Feb 2020 14:13:40 +0100 Subject: [PATCH] channeldb/migtest: remove channeldb dependency Removes this unnecessary dependency allowing migration code to use utility functions from channeldb/migtest. --- channeldb/migtest/migtest.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/channeldb/migtest/migtest.go b/channeldb/migtest/migtest.go index b6ecbafad..b2200ebf7 100644 --- a/channeldb/migtest/migtest.go +++ b/channeldb/migtest/migtest.go @@ -7,32 +7,30 @@ import ( "testing" "github.com/coreos/bbolt" - "github.com/lightningnetwork/lnd/channeldb" ) // MakeDB creates a new instance of the ChannelDB for testing purposes. A // callback which cleans up the created temporary directories is also returned // and intended to be executed after the test completes. -func MakeDB() (*channeldb.DB, func(), error) { - // First, create a temporary directory to be used for the duration of - // this test. - tempDirName, err := ioutil.TempDir("", "channeldb") +func MakeDB() (*bbolt.DB, func(), error) { + // Create temporary database for mission control. + file, err := ioutil.TempFile("", "*.db") if err != nil { return nil, nil, err } - // Next, create channeldb for the first time. - cdb, err := channeldb.Open(tempDirName) + dbPath := file.Name() + db, err := bbolt.Open(dbPath, 0600, nil) if err != nil { return nil, nil, err } cleanUp := func() { - cdb.Close() - os.RemoveAll(tempDirName) + db.Close() + os.RemoveAll(dbPath) } - return cdb, cleanUp, nil + return db, cleanUp, nil } // ApplyMigration is a helper test function that encapsulates the general steps