lntest/harness: improve error message for AssertChannelExists
predErr wasn't always being set when the predicate failed, replace with wait.NoError.
This commit is contained in:
parent
c9c7216768
commit
aa3e74043d
@ -1195,28 +1195,25 @@ func (n *NetworkHarness) AssertChannelExists(ctx context.Context,
|
|||||||
|
|
||||||
req := &lnrpc.ListChannelsRequest{}
|
req := &lnrpc.ListChannelsRequest{}
|
||||||
|
|
||||||
var predErr error
|
return wait.NoError(func() error {
|
||||||
pred := func() bool {
|
|
||||||
resp, err := node.ListChannels(ctx, req)
|
resp, err := node.ListChannels(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
predErr = fmt.Errorf("unable fetch node's channels: %v", err)
|
return fmt.Errorf("unable fetch node's channels: %v", err)
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, channel := range resp.Channels {
|
for _, channel := range resp.Channels {
|
||||||
if channel.ChannelPoint == chanPoint.String() {
|
if channel.ChannelPoint == chanPoint.String() {
|
||||||
return channel.Active
|
if channel.Active {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Errorf("channel %s inactive",
|
||||||
|
chanPoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := wait.Predicate(pred, time.Second*15); err != nil {
|
return fmt.Errorf("channel %s not found", chanPoint)
|
||||||
return fmt.Errorf("channel not found: %v", predErr)
|
}, 15*time.Second)
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DumpLogs reads the current logs generated by the passed node, and returns
|
// DumpLogs reads the current logs generated by the passed node, and returns
|
||||||
|
Loading…
Reference in New Issue
Block a user