mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-27 20:57:19 +02:00
multi: move mockChainIO, mockNotifier to lntest/mock
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
"github.com/lightningnetwork/lnd/lntest/mock"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -28,16 +29,18 @@ func tempDecayedLogPath(t *testing.T) string {
|
||||
}
|
||||
|
||||
// startup sets up the DecayedLog and possibly the garbage collector.
|
||||
func startup(dbPath string, notifier bool) (sphinx.ReplayLog, *mockNotifier,
|
||||
*sphinx.HashPrefix, error) {
|
||||
func startup(dbPath string, notifier bool) (sphinx.ReplayLog,
|
||||
*mock.ChainNotifier, *sphinx.HashPrefix, error) {
|
||||
|
||||
var log sphinx.ReplayLog
|
||||
var chainNotifier *mockNotifier
|
||||
var chainNotifier *mock.ChainNotifier
|
||||
if notifier {
|
||||
|
||||
// Create the MockNotifier which triggers the garbage collector
|
||||
chainNotifier = &mockNotifier{
|
||||
epochChan: make(chan *chainntnfs.BlockEpoch, 1),
|
||||
chainNotifier = &mock.ChainNotifier{
|
||||
SpendChan: make(chan *chainntnfs.SpendDetail),
|
||||
EpochChan: make(chan *chainntnfs.BlockEpoch, 1),
|
||||
ConfChan: make(chan *chainntnfs.TxConfirmation),
|
||||
}
|
||||
|
||||
// Initialize the DecayedLog object
|
||||
@@ -99,7 +102,7 @@ func TestDecayedLogGarbageCollector(t *testing.T) {
|
||||
// should remove the entry by block 100001.
|
||||
|
||||
// Send block 100000
|
||||
notifier.epochChan <- &chainntnfs.BlockEpoch{
|
||||
notifier.EpochChan <- &chainntnfs.BlockEpoch{
|
||||
Height: 100000,
|
||||
}
|
||||
|
||||
@@ -114,7 +117,7 @@ func TestDecayedLogGarbageCollector(t *testing.T) {
|
||||
}
|
||||
|
||||
// Send block 100001 (expiry block)
|
||||
notifier.epochChan <- &chainntnfs.BlockEpoch{
|
||||
notifier.EpochChan <- &chainntnfs.BlockEpoch{
|
||||
Height: 100001,
|
||||
}
|
||||
|
||||
@@ -175,7 +178,7 @@ func TestDecayedLogPersistentGarbageCollector(t *testing.T) {
|
||||
|
||||
// Send a block notification to the garbage collector that expires
|
||||
// the stored CLTV.
|
||||
notifier2.epochChan <- &chainntnfs.BlockEpoch{
|
||||
notifier2.EpochChan <- &chainntnfs.BlockEpoch{
|
||||
Height: int32(100001),
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/go-errors/errors"
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
@@ -26,6 +25,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/htlcswitch/hop"
|
||||
"github.com/lightningnetwork/lnd/invoices"
|
||||
"github.com/lightningnetwork/lnd/lnpeer"
|
||||
"github.com/lightningnetwork/lnd/lntest/mock"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
@@ -170,7 +170,11 @@ func initSwitchWithDB(startingHeight uint32, db *channeldb.DB) (*Switch, error)
|
||||
FetchLastChannelUpdate: func(lnwire.ShortChannelID) (*lnwire.ChannelUpdate, error) {
|
||||
return nil, nil
|
||||
},
|
||||
Notifier: &mockNotifier{},
|
||||
Notifier: &mock.ChainNotifier{
|
||||
SpendChan: make(chan *chainntnfs.SpendDetail),
|
||||
EpochChan: make(chan *chainntnfs.BlockEpoch),
|
||||
ConfChan: make(chan *chainntnfs.TxConfirmation),
|
||||
},
|
||||
FwdEventTicker: ticker.NewForce(DefaultFwdEventInterval),
|
||||
LogEventTicker: ticker.NewForce(DefaultLogInterval),
|
||||
AckEventTicker: ticker.NewForce(DefaultAckInterval),
|
||||
@@ -853,42 +857,6 @@ func (i *mockInvoiceRegistry) HodlUnsubscribeAll(subscriber chan<- interface{})
|
||||
|
||||
var _ InvoiceDatabase = (*mockInvoiceRegistry)(nil)
|
||||
|
||||
type mockNotifier struct {
|
||||
epochChan chan *chainntnfs.BlockEpoch
|
||||
}
|
||||
|
||||
func (m *mockNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, _ []byte,
|
||||
numConfs uint32, heightHint uint32) (*chainntnfs.ConfirmationEvent, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (m *mockNotifier) RegisterBlockEpochNtfn(
|
||||
bestBlock *chainntnfs.BlockEpoch) (*chainntnfs.BlockEpochEvent, error) {
|
||||
return &chainntnfs.BlockEpochEvent{
|
||||
Epochs: m.epochChan,
|
||||
Cancel: func() {},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (m *mockNotifier) Start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockNotifier) Started() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (m *mockNotifier) Stop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint, _ []byte,
|
||||
heightHint uint32) (*chainntnfs.SpendEvent, error) {
|
||||
|
||||
return &chainntnfs.SpendEvent{
|
||||
Spend: make(chan *chainntnfs.SpendDetail),
|
||||
}, nil
|
||||
}
|
||||
|
||||
type mockCircuitMap struct {
|
||||
lookup chan *PaymentCircuit
|
||||
}
|
||||
|
Reference in New Issue
Block a user