Skip to content

Commit b621063

Browse files
committed
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.
1 parent c354fd8 commit b621063

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

discovery/gossiper_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
graphdb "github.com/lightningnetwork/lnd/graph/db"
2929
"github.com/lightningnetwork/lnd/graph/db/models"
3030
"github.com/lightningnetwork/lnd/keychain"
31+
"github.com/lightningnetwork/lnd/lnmock"
3132
"github.com/lightningnetwork/lnd/lnpeer"
3233
"github.com/lightningnetwork/lnd/lntest/mock"
3334
"github.com/lightningnetwork/lnd/lntest/wait"
@@ -715,10 +716,12 @@ func mockFindChannel(node *btcec.PublicKey, chanID lnwire.ChannelID) (
715716
}
716717

717718
type testCtx struct {
719+
t *testing.T
718720
gossiper *AuthenticatedGossiper
719721
router *mockGraphSource
720722
notifier *mockNotifier
721723
broadcastedMessage chan msgWithSenders
724+
chain *lnmock.MockChain
722725
}
723726

724727
func createTestCtx(t *testing.T, startHeight uint32, isChanPeer bool) (
@@ -730,6 +733,10 @@ func createTestCtx(t *testing.T, startHeight uint32, isChanPeer bool) (
730733
// broadcast functions won't be populated.
731734
notifier := newMockNotifier()
732735
router := newMockRouter(startHeight)
736+
chain := &lnmock.MockChain{}
737+
t.Cleanup(func() {
738+
chain.AssertExpectations(t)
739+
})
733740

734741
db := channeldb.OpenForTesting(t, t.TempDir())
735742

@@ -761,6 +768,7 @@ func createTestCtx(t *testing.T, startHeight uint32, isChanPeer bool) (
761768
}
762769

763770
gossiper := New(Config{
771+
ChainIO: chain,
764772
Notifier: notifier,
765773
Broadcast: func(senders map[route.Vertex]struct{},
766774
msgs ...lnwire.Message) error {
@@ -832,10 +840,12 @@ func createTestCtx(t *testing.T, startHeight uint32, isChanPeer bool) (
832840
})
833841

834842
return &testCtx{
843+
t: t,
835844
router: router,
836845
notifier: notifier,
837846
gossiper: gossiper,
838847
broadcastedMessage: broadcastedMessage,
848+
chain: chain,
839849
}, nil
840850
}
841851

0 commit comments

Comments
 (0)