channeldb/migtest: remove channeldb dependency
Removes this unnecessary dependency allowing migration code to use utility functions from channeldb/migtest.
This commit is contained in:
parent
4c74c0817e
commit
c357511051
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user