mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-30 19:53:21 +02:00
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:
@@ -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