lntest+itest: add new method AssertChannelInGraph
This commit replaces `AssertTopologyChannelOpen` with `AssertChannelInGraph`, which asserts a given channel edge is found. `AssertTopologyChannelOpen` only asserts a given edge has been received via the topology subscription, while we need to make sure the channel is in the graph before continuing our tests.
This commit is contained in:
25 files changed
+110
-87
No files matched your search
+7
-7
@@ -1223,8 +1223,8 @@ func (h *HarnessTest) openChannel(alice, bob *node.HarnessNode,
|
||||
|
||||
// Check that both alice and bob have seen the channel from their
|
||||
// network topology.
|
||||
h.AssertTopologyChannelOpen(alice, fundingChanPoint)
|
||||
h.AssertTopologyChannelOpen(bob, fundingChanPoint)
|
||||
h.AssertChannelInGraph(alice, fundingChanPoint)
|
||||
h.AssertChannelInGraph(bob, fundingChanPoint)
|
||||
|
||||
// Check that the channel can be seen in their ListChannels.
|
||||
h.AssertChannelExists(alice, fundingChanPoint)
|
||||
@@ -1245,8 +1245,8 @@ func (h *HarnessTest) openChannelZeroConf(alice, bob *node.HarnessNode,
|
||||
|
||||
// Check that both alice and bob have seen the channel from their
|
||||
// network topology.
|
||||
h.AssertTopologyChannelOpen(alice, fundingChanPoint)
|
||||
h.AssertTopologyChannelOpen(bob, fundingChanPoint)
|
||||
h.AssertChannelInGraph(alice, fundingChanPoint)
|
||||
h.AssertChannelInGraph(bob, fundingChanPoint)
|
||||
|
||||
// Finally, check that the channel can be seen in their ListChannels.
|
||||
h.AssertChannelExists(alice, fundingChanPoint)
|
||||
@@ -1830,8 +1830,8 @@ func (h *HarnessTest) OpenMultiChannelsAsync(
|
||||
if !req.Param.Private {
|
||||
// Check that both alice and bob have seen the channel
|
||||
// from their channel watch request.
|
||||
h.AssertTopologyChannelOpen(req.Local, cp)
|
||||
h.AssertTopologyChannelOpen(req.Remote, cp)
|
||||
h.AssertChannelInGraph(req.Local, cp)
|
||||
h.AssertChannelInGraph(req.Remote, cp)
|
||||
}
|
||||
|
||||
// Finally, check that the channel can be seen in their
|
||||
@@ -2327,7 +2327,7 @@ func (h *HarnessTest) openChannelsForNodes(nodes []*node.HarnessNode,
|
||||
if !p.Private {
|
||||
for _, node := range nodes {
|
||||
for _, chanPoint := range resp {
|
||||
h.AssertTopologyChannelOpen(node, chanPoint)
|
||||
h.AssertChannelInGraph(node, chanPoint)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+33
-10
@@ -403,15 +403,6 @@ func (h HarnessTest) WaitForChannelOpenEvent(
|
||||
return resp.ChanOpen.ChannelPoint
|
||||
}
|
||||
|
||||
// AssertTopologyChannelOpen asserts that a given channel outpoint is seen by
|
||||
// the passed node's network topology.
|
||||
func (h *HarnessTest) AssertTopologyChannelOpen(hn *node.HarnessNode,
|
||||
chanPoint *lnrpc.ChannelPoint) {
|
||||
|
||||
err := hn.Watcher.WaitForChannelOpen(chanPoint)
|
||||
require.NoErrorf(h, err, "%s didn't report channel", hn.Name())
|
||||
}
|
||||
|
||||
// AssertChannelExists asserts that an active channel identified by the
|
||||
// specified channel point exists from the point-of-view of the node.
|
||||
func (h *HarnessTest) AssertChannelExists(hn *node.HarnessNode,
|
||||
@@ -506,7 +497,8 @@ func (h *HarnessTest) findChannel(hn *node.HarnessNode,
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("channel not found using %s", chanPoint)
|
||||
return nil, fmt.Errorf("%s: channel not found using %s", hn.Name(),
|
||||
fp.String())
|
||||
}
|
||||
|
||||
// ReceiveCloseChannelUpdate waits until a message or an error is received on
|
||||
@@ -1945,6 +1937,37 @@ func (h *HarnessTest) AssertNotInGraph(hn *node.HarnessNode, chanID uint64) {
|
||||
"found in graph")
|
||||
}
|
||||
|
||||
// AssertChannelInGraph asserts that a given channel is found in the graph.
|
||||
func (h *HarnessTest) AssertChannelInGraph(hn *node.HarnessNode,
|
||||
chanPoint *lnrpc.ChannelPoint) *lnrpc.ChannelEdge {
|
||||
|
||||
ctxt, cancel := context.WithCancel(h.runCtx)
|
||||
defer cancel()
|
||||
|
||||
var edge *lnrpc.ChannelEdge
|
||||
|
||||
op := h.OutPointFromChannelPoint(chanPoint)
|
||||
err := wait.NoError(func() error {
|
||||
resp, err := hn.RPC.LN.GetChanInfo(
|
||||
ctxt, &lnrpc.ChanInfoRequest{
|
||||
ChanPoint: op.String(),
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("channel %s not found in graph: %w",
|
||||
op, err)
|
||||
}
|
||||
|
||||
edge = resp
|
||||
|
||||
return nil
|
||||
}, DefaultTimeout)
|
||||
require.NoError(h, err, "%s: timeout finding channel in graph",
|
||||
hn.Name())
|
||||
|
||||
return edge
|
||||
}
|
||||
|
||||
// AssertTxAtHeight gets all of the transactions that a node's wallet has a
|
||||
// record of at the target height, and finds and returns the tx with the target
|
||||
// txid, failing if it is not found.
|
||||
|
||||
Reference in new issue
Block a user