Skip to content

Commit d27ff34

Browse files
committed
lntest+itest: rename AssertNumEdges to AssertNumActiveEdges
To properly reflect what the assertion is.
1 parent 35992e1 commit d27ff34

File tree

6 files changed

+57
-18
lines changed

6 files changed

+57
-18
lines changed

itest/lnd_channel_graph_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,17 +237,17 @@ func testUnannouncedChannels(ht *lntest.HarnessTest) {
237237
fundingChanPoint := ht.WaitForChannelOpenEvent(chanOpenUpdate)
238238

239239
// Alice should have 1 edge in her graph.
240-
ht.AssertNumEdges(alice, 1, true)
240+
ht.AssertNumActiveEdges(alice, 1, true)
241241

242242
// Channels should not be announced yet, hence Alice should have no
243243
// announced edges in her graph.
244-
ht.AssertNumEdges(alice, 0, false)
244+
ht.AssertNumActiveEdges(alice, 0, false)
245245

246246
// Mine 4 more blocks, and check that the channel is now announced.
247247
ht.MineBlocks(4)
248248

249249
// Give the network a chance to learn that auth proof is confirmed.
250-
ht.AssertNumEdges(alice, 1, false)
250+
ht.AssertNumActiveEdges(alice, 1, false)
251251

252252
// Close the channel used during the test.
253253
ht.CloseChannel(alice, fundingChanPoint)

itest/lnd_mpp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func (m *mppTestScenario) openChannels(r *mppOpenChannelRequest) {
299299
}
300300

301301
// Each node should have exactly 6 edges.
302-
m.ht.AssertNumEdges(hn, len(m.channelPoints), false)
302+
m.ht.AssertNumActiveEdges(hn, len(m.channelPoints), false)
303303
}
304304
}
305305

itest/lnd_open_channel_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func testOpenChannelAfterReorg(ht *lntest.HarnessTest) {
8484
ht.AssertTopologyChannelOpen(bob, chanPoint)
8585

8686
// Alice should now have 1 edge in her graph.
87-
ht.AssertNumEdges(alice, 1, true)
87+
ht.AssertNumActiveEdges(alice, 1, true)
8888

8989
// Now we disconnect Alice's chain backend from the original miner, and
9090
// connect the two miners together. Since the temporary miner knows
@@ -112,7 +112,7 @@ func testOpenChannelAfterReorg(ht *lntest.HarnessTest) {
112112

113113
// Since the fundingtx was reorged out, Alice should now have no edges
114114
// in her graph.
115-
ht.AssertNumEdges(alice, 0, true)
115+
ht.AssertNumActiveEdges(alice, 0, true)
116116

117117
// Cleanup by mining the funding tx again, then closing the channel.
118118
block = ht.MineBlocksAndAssertNumTxes(1, 1)[0]

itest/lnd_route_blinding_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ func testMPPToSingleBlindedPath(ht *lntest.HarnessTest) {
985985
}
986986

987987
// Each node should have exactly numPublic edges.
988-
ht.AssertNumEdges(hn, numPublic, false)
988+
ht.AssertNumActiveEdges(hn, numPublic, false)
989989
}
990990

991991
// Make Dave create an invoice with a blinded path for Alice to pay.
@@ -1156,7 +1156,7 @@ func testBlindedRouteDummyHops(ht *lntest.HarnessTest) {
11561156
}
11571157

11581158
// Each node should have exactly 5 edges.
1159-
ht.AssertNumEdges(hn, len(channelPoints), false)
1159+
ht.AssertNumActiveEdges(hn, len(channelPoints), false)
11601160
}
11611161

11621162
// Make Dave create an invoice with a blinded path for Alice to pay.
@@ -1325,7 +1325,7 @@ func testMPPToMultipleBlindedPaths(ht *lntest.HarnessTest) {
13251325
}
13261326

13271327
// Each node should have exactly 5 edges.
1328-
ht.AssertNumEdges(hn, len(channelPoints), false)
1328+
ht.AssertNumActiveEdges(hn, len(channelPoints), false)
13291329
}
13301330

13311331
// Ok now make a payment that must be split to succeed.

itest/lnd_routing_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -591,12 +591,12 @@ func testPrivateChannels(ht *lntest.HarnessTest) {
591591

592592
// Carol and Alice should know about 4, while Bob and Dave should only
593593
// know about 3, since one channel is private.
594-
ht.AssertNumEdges(alice, 4, true)
595-
ht.AssertNumEdges(alice, 3, false)
596-
ht.AssertNumEdges(bob, 3, true)
597-
ht.AssertNumEdges(carol, 4, true)
598-
ht.AssertNumEdges(carol, 3, false)
599-
ht.AssertNumEdges(dave, 3, true)
594+
ht.AssertNumActiveEdges(alice, 4, true)
595+
ht.AssertNumActiveEdges(alice, 3, false)
596+
ht.AssertNumActiveEdges(bob, 3, true)
597+
ht.AssertNumActiveEdges(carol, 4, true)
598+
ht.AssertNumActiveEdges(carol, 3, false)
599+
ht.AssertNumActiveEdges(dave, 3, true)
600600

601601
// Close all channels.
602602
ht.CloseChannel(alice, chanPointAlice)

lntest/harness_assertion.go

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ func (h *HarnessTest) EnsureConnected(a, b *node.HarnessNode) {
240240
h.AssertPeerConnected(b, a)
241241
}
242242

243-
// AssertNumEdges checks that an expected number of edges can be found in the
244-
// node specified.
245-
func (h *HarnessTest) AssertNumEdges(hn *node.HarnessNode,
243+
// AssertNumActiveEdges checks that an expected number of active edges can be
244+
// found in the node specified.
245+
func (h *HarnessTest) AssertNumActiveEdges(hn *node.HarnessNode,
246246
expected int, includeUnannounced bool) []*lnrpc.ChannelEdge {
247247

248248
var edges []*lnrpc.ChannelEdge
@@ -293,6 +293,45 @@ func (h *HarnessTest) AssertNumEdges(hn *node.HarnessNode,
293293
return edges
294294
}
295295

296+
// AssertNumEdges checks that an expected number of edges can be found in the
297+
// node specified.
298+
func (h *HarnessTest) AssertNumEdges(hn *node.HarnessNode,
299+
expected int, includeUnannounced bool) []*lnrpc.ChannelEdge {
300+
301+
var edges []*lnrpc.ChannelEdge
302+
303+
old := hn.State.Edge.Public
304+
if includeUnannounced {
305+
old = hn.State.Edge.Total
306+
}
307+
308+
err := wait.NoError(func() error {
309+
req := &lnrpc.ChannelGraphRequest{
310+
IncludeUnannounced: includeUnannounced,
311+
}
312+
resp := hn.RPC.DescribeGraph(req)
313+
total := len(resp.Edges)
314+
315+
if total-old == expected {
316+
if expected != 0 {
317+
// NOTE: assume edges come in ascending order
318+
// that the old edges are at the front of the
319+
// slice.
320+
edges = resp.Edges[old:]
321+
}
322+
323+
return nil
324+
}
325+
326+
return errNumNotMatched(hn.Name(), "num of channel edges",
327+
expected, total-old, total, old)
328+
}, DefaultTimeout)
329+
330+
require.NoError(h, err, "timeout while checking for edges")
331+
332+
return edges
333+
}
334+
296335
// ReceiveOpenChannelUpdate waits until a message is received on the stream or
297336
// the timeout is reached.
298337
func (h *HarnessTest) ReceiveOpenChannelUpdate(

0 commit comments

Comments
 (0)