From 905990eb540c77f4743d9b439114c9550bf4b671 Mon Sep 17 00:00:00 2001 From: Andras Banki-Horvath Date: Wed, 24 Jun 2020 12:57:23 +0200 Subject: [PATCH] sweep: use channeldb.MakeTestDB --- sweep/store_test.go | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/sweep/store_test.go b/sweep/store_test.go index 3738f6c9..b27efb31 100644 --- a/sweep/store_test.go +++ b/sweep/store_test.go @@ -1,8 +1,6 @@ package sweep import ( - "io/ioutil" - "os" "testing" "github.com/btcsuite/btcd/chaincfg/chainhash" @@ -10,38 +8,13 @@ import ( "github.com/lightningnetwork/lnd/channeldb" ) -// makeTestDB 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 makeTestDB() (*channeldb.DB, func(), error) { - // First, create a temporary directory to be used for the duration of - // this test. - tempDirName, err := ioutil.TempDir("", "channeldb") - if err != nil { - return nil, nil, err - } - - // Next, create channeldb for the first time. - cdb, err := channeldb.Open(tempDirName) - if err != nil { - return nil, nil, err - } - - cleanUp := func() { - cdb.Close() - os.RemoveAll(tempDirName) - } - - return cdb, cleanUp, nil -} - // TestStore asserts that the store persists the presented data to disk and is // able to retrieve it again. func TestStore(t *testing.T) { t.Run("bolt", func(t *testing.T) { // Create new store. - cdb, cleanUp, err := makeTestDB() + cdb, cleanUp, err := channeldb.MakeTestDB() if err != nil { t.Fatalf("unable to open channel db: %v", err) }