From b6210632f24bdb335f566a97cd2cfedd3a00f400 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Fri, 7 Feb 2025 15:33:39 +0200 Subject: [PATCH] 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. --- discovery/gossiper_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/discovery/gossiper_test.go b/discovery/gossiper_test.go index c493d2124..8d1ce32e1 100644 --- a/discovery/gossiper_test.go +++ b/discovery/gossiper_test.go @@ -28,6 +28,7 @@ import ( graphdb "github.com/lightningnetwork/lnd/graph/db" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/keychain" + "github.com/lightningnetwork/lnd/lnmock" "github.com/lightningnetwork/lnd/lnpeer" "github.com/lightningnetwork/lnd/lntest/mock" "github.com/lightningnetwork/lnd/lntest/wait" @@ -715,10 +716,12 @@ func mockFindChannel(node *btcec.PublicKey, chanID lnwire.ChannelID) ( } type testCtx struct { + t *testing.T gossiper *AuthenticatedGossiper router *mockGraphSource notifier *mockNotifier broadcastedMessage chan msgWithSenders + chain *lnmock.MockChain } 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. notifier := newMockNotifier() router := newMockRouter(startHeight) + chain := &lnmock.MockChain{} + t.Cleanup(func() { + chain.AssertExpectations(t) + }) db := channeldb.OpenForTesting(t, t.TempDir()) @@ -761,6 +768,7 @@ func createTestCtx(t *testing.T, startHeight uint32, isChanPeer bool) ( } gossiper := New(Config{ + ChainIO: chain, Notifier: notifier, Broadcast: func(senders map[route.Vertex]struct{}, msgs ...lnwire.Message) error { @@ -832,10 +840,12 @@ func createTestCtx(t *testing.T, startHeight uint32, isChanPeer bool) ( }) return &testCtx{ + t: t, router: router, notifier: notifier, gossiper: gossiper, broadcastedMessage: broadcastedMessage, + chain: chain, }, nil }