channeldb/migtest: remove channeldb dependency

Removes this unnecessary dependency allowing migration code to use
utility functions from channeldb/migtest.
This commit is contained in:
Joost Jager 2020-02-21 14:13:40 +01:00
parent 4c74c0817e
commit c357511051
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7

@ -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