mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-07 22:10:27 +02:00
discovery: prep testCtx with a mock Chain
This is in preparation for moving the funding transaction validation code to the gossiper from the graph.Builder since then the gossiper will start making GetBlockHash/GetBlock and GetUtxo calls.
This commit is contained in:
@ -28,6 +28,7 @@ import (
|
|||||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||||
"github.com/lightningnetwork/lnd/graph/db/models"
|
"github.com/lightningnetwork/lnd/graph/db/models"
|
||||||
"github.com/lightningnetwork/lnd/keychain"
|
"github.com/lightningnetwork/lnd/keychain"
|
||||||
|
"github.com/lightningnetwork/lnd/lnmock"
|
||||||
"github.com/lightningnetwork/lnd/lnpeer"
|
"github.com/lightningnetwork/lnd/lnpeer"
|
||||||
"github.com/lightningnetwork/lnd/lntest/mock"
|
"github.com/lightningnetwork/lnd/lntest/mock"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
@ -715,10 +716,12 @@ func mockFindChannel(node *btcec.PublicKey, chanID lnwire.ChannelID) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
type testCtx struct {
|
type testCtx struct {
|
||||||
|
t *testing.T
|
||||||
gossiper *AuthenticatedGossiper
|
gossiper *AuthenticatedGossiper
|
||||||
router *mockGraphSource
|
router *mockGraphSource
|
||||||
notifier *mockNotifier
|
notifier *mockNotifier
|
||||||
broadcastedMessage chan msgWithSenders
|
broadcastedMessage chan msgWithSenders
|
||||||
|
chain *lnmock.MockChain
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTestCtx(t *testing.T, startHeight uint32, isChanPeer bool) (
|
func createTestCtx(t *testing.T, startHeight uint32, isChanPeer bool) (
|
||||||
@ -730,6 +733,10 @@ func createTestCtx(t *testing.T, startHeight uint32, isChanPeer bool) (
|
|||||||
// broadcast functions won't be populated.
|
// broadcast functions won't be populated.
|
||||||
notifier := newMockNotifier()
|
notifier := newMockNotifier()
|
||||||
router := newMockRouter(startHeight)
|
router := newMockRouter(startHeight)
|
||||||
|
chain := &lnmock.MockChain{}
|
||||||
|
t.Cleanup(func() {
|
||||||
|
chain.AssertExpectations(t)
|
||||||
|
})
|
||||||
|
|
||||||
db := channeldb.OpenForTesting(t, t.TempDir())
|
db := channeldb.OpenForTesting(t, t.TempDir())
|
||||||
|
|
||||||
@ -761,6 +768,7 @@ func createTestCtx(t *testing.T, startHeight uint32, isChanPeer bool) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
gossiper := New(Config{
|
gossiper := New(Config{
|
||||||
|
ChainIO: chain,
|
||||||
Notifier: notifier,
|
Notifier: notifier,
|
||||||
Broadcast: func(senders map[route.Vertex]struct{},
|
Broadcast: func(senders map[route.Vertex]struct{},
|
||||||
msgs ...lnwire.Message) error {
|
msgs ...lnwire.Message) error {
|
||||||
@ -832,10 +840,12 @@ func createTestCtx(t *testing.T, startHeight uint32, isChanPeer bool) (
|
|||||||
})
|
})
|
||||||
|
|
||||||
return &testCtx{
|
return &testCtx{
|
||||||
|
t: t,
|
||||||
router: router,
|
router: router,
|
||||||
notifier: notifier,
|
notifier: notifier,
|
||||||
gossiper: gossiper,
|
gossiper: gossiper,
|
||||||
broadcastedMessage: broadcastedMessage,
|
broadcastedMessage: broadcastedMessage,
|
||||||
|
chain: chain,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user