From cbb099fc4faf8020f4df5a9dd731b371a0aefed3 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Fri, 8 Nov 2024 16:52:59 +0800 Subject: [PATCH] lntest+itest: remove `AssertNumActiveEdges` This is no longer needed since we don't have standby nodes, plus it's causing panic in windows build due to `edge.Policy` being nil. --- itest/lnd_channel_graph_test.go | 6 ++-- itest/lnd_mpp_test.go | 2 +- itest/lnd_open_channel_test.go | 4 +-- itest/lnd_route_blinding_test.go | 6 ++-- itest/lnd_routing_test.go | 12 ++++---- lntest/harness_assertion.go | 53 -------------------------------- 6 files changed, 15 insertions(+), 68 deletions(-) diff --git a/itest/lnd_channel_graph_test.go b/itest/lnd_channel_graph_test.go index a7ad37aca7..b21da219ab 100644 --- a/itest/lnd_channel_graph_test.go +++ b/itest/lnd_channel_graph_test.go @@ -237,17 +237,17 @@ func testUnannouncedChannels(ht *lntest.HarnessTest) { ht.WaitForChannelOpenEvent(chanOpenUpdate) // Alice should have 1 edge in her graph. - ht.AssertNumActiveEdges(alice, 1, true) + ht.AssertNumEdges(alice, 1, true) // Channels should not be announced yet, hence Alice should have no // announced edges in her graph. - ht.AssertNumActiveEdges(alice, 0, false) + ht.AssertNumEdges(alice, 0, false) // Mine 4 more blocks, and check that the channel is now announced. ht.MineBlocks(4) // Give the network a chance to learn that auth proof is confirmed. - ht.AssertNumActiveEdges(alice, 1, false) + ht.AssertNumEdges(alice, 1, false) } func testGraphTopologyNotifications(ht *lntest.HarnessTest) { diff --git a/itest/lnd_mpp_test.go b/itest/lnd_mpp_test.go index 0316e253ae..7bc23da2a8 100644 --- a/itest/lnd_mpp_test.go +++ b/itest/lnd_mpp_test.go @@ -404,7 +404,7 @@ func (m *mppTestScenario) openChannels(r *mppOpenChannelRequest) { } // Each node should have exactly 6 edges. - m.ht.AssertNumActiveEdges(hn, len(m.channelPoints), false) + m.ht.AssertNumEdges(hn, len(m.channelPoints), false) } } diff --git a/itest/lnd_open_channel_test.go b/itest/lnd_open_channel_test.go index 66930a6c24..47311b25ea 100644 --- a/itest/lnd_open_channel_test.go +++ b/itest/lnd_open_channel_test.go @@ -88,7 +88,7 @@ func testOpenChannelAfterReorg(ht *lntest.HarnessTest) { ht.AssertChannelInGraph(bob, chanPoint) // Alice should now have 1 edge in her graph. - ht.AssertNumActiveEdges(alice, 1, true) + ht.AssertNumEdges(alice, 1, true) // Now we disconnect Alice's chain backend from the original miner, and // connect the two miners together. Since the temporary miner knows @@ -116,7 +116,7 @@ func testOpenChannelAfterReorg(ht *lntest.HarnessTest) { // Since the fundingtx was reorged out, Alice should now have no edges // in her graph. - ht.AssertNumActiveEdges(alice, 0, true) + ht.AssertNumEdges(alice, 0, true) // Cleanup by mining the funding tx again, then closing the channel. block = ht.MineBlocksAndAssertNumTxes(1, 1)[0] diff --git a/itest/lnd_route_blinding_test.go b/itest/lnd_route_blinding_test.go index 25cd38d892..d85f3fcac4 100644 --- a/itest/lnd_route_blinding_test.go +++ b/itest/lnd_route_blinding_test.go @@ -939,7 +939,7 @@ func testMPPToSingleBlindedPath(ht *lntest.HarnessTest) { } // Each node should have exactly numPublic edges. - ht.AssertNumActiveEdges(hn, numPublic, false) + ht.AssertNumEdges(hn, numPublic, false) } // Make Dave create an invoice with a blinded path for Alice to pay. @@ -1110,7 +1110,7 @@ func testBlindedRouteDummyHops(ht *lntest.HarnessTest) { } // Each node should have exactly 5 edges. - ht.AssertNumActiveEdges(hn, len(channelPoints), false) + ht.AssertNumEdges(hn, len(channelPoints), false) } // Make Dave create an invoice with a blinded path for Alice to pay. @@ -1280,7 +1280,7 @@ func testMPPToMultipleBlindedPaths(ht *lntest.HarnessTest) { } // Each node should have exactly 5 edges. - ht.AssertNumActiveEdges(hn, len(channelPoints), false) + ht.AssertNumEdges(hn, len(channelPoints), false) } // Ok now make a payment that must be split to succeed. diff --git a/itest/lnd_routing_test.go b/itest/lnd_routing_test.go index 63c5d54189..950b24d24b 100644 --- a/itest/lnd_routing_test.go +++ b/itest/lnd_routing_test.go @@ -589,12 +589,12 @@ func testPrivateChannels(ht *lntest.HarnessTest) { // Carol and Alice should know about 4, while Bob and Dave should only // know about 3, since one channel is private. - ht.AssertNumActiveEdges(alice, 4, true) - ht.AssertNumActiveEdges(alice, 3, false) - ht.AssertNumActiveEdges(bob, 3, true) - ht.AssertNumActiveEdges(carol, 4, true) - ht.AssertNumActiveEdges(carol, 3, false) - ht.AssertNumActiveEdges(dave, 3, true) + ht.AssertNumEdges(alice, 4, true) + ht.AssertNumEdges(alice, 3, false) + ht.AssertNumEdges(bob, 3, true) + ht.AssertNumEdges(carol, 4, true) + ht.AssertNumEdges(carol, 3, false) + ht.AssertNumEdges(dave, 3, true) } // testInvoiceRoutingHints tests that the routing hints for an invoice are diff --git a/lntest/harness_assertion.go b/lntest/harness_assertion.go index a167119652..c684941f73 100644 --- a/lntest/harness_assertion.go +++ b/lntest/harness_assertion.go @@ -19,7 +19,6 @@ import ( "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc/invoicesrpc" "github.com/lightningnetwork/lnd/lnrpc/routerrpc" @@ -241,58 +240,6 @@ func (h *HarnessTest) EnsureConnected(a, b *node.HarnessNode) { h.AssertPeerConnected(b, a) } -// AssertNumActiveEdges checks that an expected number of active edges can be -// found in the node specified. -func (h *HarnessTest) AssertNumActiveEdges(hn *node.HarnessNode, - expected int, includeUnannounced bool) []*lnrpc.ChannelEdge { - - var edges []*lnrpc.ChannelEdge - - old := hn.State.Edge.Public - if includeUnannounced { - old = hn.State.Edge.Total - } - - // filterDisabled is a helper closure that filters out disabled - // channels. - filterDisabled := func(edge *lnrpc.ChannelEdge) bool { - if edge.Node1Policy.Disabled { - return false - } - if edge.Node2Policy.Disabled { - return false - } - return true - } - - err := wait.NoError(func() error { - req := &lnrpc.ChannelGraphRequest{ - IncludeUnannounced: includeUnannounced, - } - resp := hn.RPC.DescribeGraph(req) - activeEdges := fn.Filter(filterDisabled, resp.Edges) - total := len(activeEdges) - - if total-old == expected { - if expected != 0 { - // NOTE: assume edges come in ascending order - // that the old edges are at the front of the - // slice. - edges = activeEdges[old:] - } - - return nil - } - - return errNumNotMatched(hn.Name(), "num of channel edges", - expected, total-old, total, old) - }, DefaultTimeout) - - require.NoError(h, err, "timeout while checking for edges") - - return edges -} - // AssertNumEdges checks that an expected number of edges can be found in the // node specified. func (h *HarnessTest) AssertNumEdges(hn *node.HarnessNode,