mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-20 16:50:54 +02:00
itest: assertions to check channel status
This commit is contained in:
parent
dc42b160a0
commit
20e731b636
@ -352,6 +352,31 @@ func (h *HarnessTest) AssertTopologyChannelOpen(hn *node.HarnessNode,
|
|||||||
func (h *HarnessTest) AssertChannelExists(hn *node.HarnessNode,
|
func (h *HarnessTest) AssertChannelExists(hn *node.HarnessNode,
|
||||||
cp *lnrpc.ChannelPoint) *lnrpc.Channel {
|
cp *lnrpc.ChannelPoint) *lnrpc.Channel {
|
||||||
|
|
||||||
|
return h.assertChannelStatus(hn, cp, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AssertChannelActive checks if a channel identified by the specified channel
|
||||||
|
// point is active.
|
||||||
|
func (h *HarnessTest) AssertChannelActive(hn *node.HarnessNode,
|
||||||
|
cp *lnrpc.ChannelPoint) *lnrpc.Channel {
|
||||||
|
|
||||||
|
return h.assertChannelStatus(hn, cp, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AssertChannelInactive checks if a channel identified by the specified channel
|
||||||
|
// point is inactive.
|
||||||
|
func (h *HarnessTest) AssertChannelInactive(hn *node.HarnessNode,
|
||||||
|
cp *lnrpc.ChannelPoint) *lnrpc.Channel {
|
||||||
|
|
||||||
|
return h.assertChannelStatus(hn, cp, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
// assertChannelStatus asserts that a channel identified by the specified
|
||||||
|
// channel point exists from the point-of-view of the node and that it is either
|
||||||
|
// active or inactive depending on the value of the active parameter.
|
||||||
|
func (h *HarnessTest) assertChannelStatus(hn *node.HarnessNode,
|
||||||
|
cp *lnrpc.ChannelPoint, active bool) *lnrpc.Channel {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
channel *lnrpc.Channel
|
channel *lnrpc.Channel
|
||||||
err error
|
err error
|
||||||
@ -364,11 +389,12 @@ func (h *HarnessTest) AssertChannelExists(hn *node.HarnessNode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check whether the channel is active, exit early if it is.
|
// Check whether the channel is active, exit early if it is.
|
||||||
if channel.Active {
|
if channel.Active == active {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Errorf("channel point not active")
|
return fmt.Errorf("expected channel_active=%v, got %v",
|
||||||
|
active, channel.Active)
|
||||||
}, DefaultTimeout)
|
}, DefaultTimeout)
|
||||||
|
|
||||||
require.NoErrorf(h, err, "%s: timeout checking for channel point: %v",
|
require.NoErrorf(h, err, "%s: timeout checking for channel point: %v",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user