chainntnfs/btcdnotify: initialize with height hint cache
This commit is contained in:
1 file changed
+24
-1
@@ -3,18 +3,41 @@
|
|||||||
package btcdnotify
|
package btcdnotify
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io/ioutil"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/integration/rpctest"
|
"github.com/btcsuite/btcd/integration/rpctest"
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func initHintCache(t *testing.T) *chainntnfs.HeightHintCache {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
tempDir, err := ioutil.TempDir("", "kek")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unable to create temp dir: %v", err)
|
||||||
|
}
|
||||||
|
db, err := channeldb.Open(tempDir)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unable to create db: %v", err)
|
||||||
|
}
|
||||||
|
hintCache, err := chainntnfs.NewHeightHintCache(db)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unable to create hint cache: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return hintCache
|
||||||
|
}
|
||||||
|
|
||||||
// setUpNotifier is a helper function to start a new notifier backed by a btcd
|
// setUpNotifier is a helper function to start a new notifier backed by a btcd
|
||||||
// driver.
|
// driver.
|
||||||
func setUpNotifier(t *testing.T, h *rpctest.Harness) *BtcdNotifier {
|
func setUpNotifier(t *testing.T, h *rpctest.Harness) *BtcdNotifier {
|
||||||
|
hintCache := initHintCache(t)
|
||||||
|
|
||||||
rpcCfg := h.RPCConfig()
|
rpcCfg := h.RPCConfig()
|
||||||
notifier, err := New(&rpcCfg)
|
notifier, err := New(&rpcCfg, hintCache, hintCache)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create notifier: %v", err)
|
t.Fatalf("unable to create notifier: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user