Skip to content

Commit

Permalink
lnd: utxo nursery test to use channeldb.MakeTestDB
Browse files Browse the repository at this point in the history
  • Loading branch information
bhandras committed Jun 29, 2020
1 parent d2f2383 commit 033354e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions utxonursery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package lnd
import (
"bytes"
"fmt"
"io/ioutil"
"math"
"os"
"reflect"
Expand Down Expand Up @@ -407,6 +406,7 @@ type nurseryTestContext struct {
sweeper *mockSweeper
timeoutChan chan chan time.Time
t *testing.T
dbCleanup func()
}

func createNurseryTestContext(t *testing.T,
Expand All @@ -416,12 +416,7 @@ func createNurseryTestContext(t *testing.T,
// alternative, mocking nurseryStore, is not chosen because there is
// still considerable logic in the store.

tempDirName, err := ioutil.TempDir("", "channeldb")
if err != nil {
t.Fatalf("unable to create temp dir: %v", err)
}

cdb, err := channeldb.Open(tempDirName)
cdb, cleanup, err := channeldb.MakeTestDB()
if err != nil {
t.Fatalf("unable to open channeldb: %v", err)
}
Expand Down Expand Up @@ -484,6 +479,7 @@ func createNurseryTestContext(t *testing.T,
sweeper: sweeper,
timeoutChan: timeoutChan,
t: t,
dbCleanup: cleanup,
}

ctx.receiveTx = func() wire.MsgTx {
Expand Down Expand Up @@ -531,6 +527,8 @@ func (ctx *nurseryTestContext) notifyEpoch(height int32) {
}

func (ctx *nurseryTestContext) finish() {
defer ctx.dbCleanup()

// Add a final restart point in this state
ctx.restart()

Expand Down

0 comments on commit 033354e

Please sign in to comment.