lnd: utxo nursery test to use channeldb.MakeTestDB

This commit is contained in:
Andras Banki-Horvath 2020-06-24 15:41:41 +02:00
parent 905990eb54
commit 3cdbb341da
No known key found for this signature in database
GPG Key ID: 80E5375C094198D8

@ -5,7 +5,6 @@ package lnd
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"io/ioutil"
"math" "math"
"os" "os"
"reflect" "reflect"
@ -407,6 +406,7 @@ type nurseryTestContext struct {
sweeper *mockSweeper sweeper *mockSweeper
timeoutChan chan chan time.Time timeoutChan chan chan time.Time
t *testing.T t *testing.T
dbCleanup func()
} }
func createNurseryTestContext(t *testing.T, func createNurseryTestContext(t *testing.T,
@ -416,12 +416,7 @@ func createNurseryTestContext(t *testing.T,
// alternative, mocking nurseryStore, is not chosen because there is // alternative, mocking nurseryStore, is not chosen because there is
// still considerable logic in the store. // still considerable logic in the store.
tempDirName, err := ioutil.TempDir("", "channeldb") cdb, cleanup, err := channeldb.MakeTestDB()
if err != nil {
t.Fatalf("unable to create temp dir: %v", err)
}
cdb, err := channeldb.Open(tempDirName)
if err != nil { if err != nil {
t.Fatalf("unable to open channeldb: %v", err) t.Fatalf("unable to open channeldb: %v", err)
} }
@ -484,6 +479,7 @@ func createNurseryTestContext(t *testing.T,
sweeper: sweeper, sweeper: sweeper,
timeoutChan: timeoutChan, timeoutChan: timeoutChan,
t: t, t: t,
dbCleanup: cleanup,
} }
ctx.receiveTx = func() wire.MsgTx { ctx.receiveTx = func() wire.MsgTx {
@ -531,6 +527,8 @@ func (ctx *nurseryTestContext) notifyEpoch(height int32) {
} }
func (ctx *nurseryTestContext) finish() { func (ctx *nurseryTestContext) finish() {
defer ctx.dbCleanup()
// Add a final restart point in this state // Add a final restart point in this state
ctx.restart() ctx.restart()