From aa3e74043daa4ad1ded01f932ce56ee7665ea19b Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Tue, 19 Nov 2019 20:12:48 -0800 Subject: [PATCH] lntest/harness: improve error message for AssertChannelExists predErr wasn't always being set when the predicate failed, replace with wait.NoError. --- lntest/harness.go | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/lntest/harness.go b/lntest/harness.go index d017b75dc..524177504 100644 --- a/lntest/harness.go +++ b/lntest/harness.go @@ -1195,28 +1195,25 @@ func (n *NetworkHarness) AssertChannelExists(ctx context.Context, req := &lnrpc.ListChannelsRequest{} - var predErr error - pred := func() bool { + return wait.NoError(func() error { resp, err := node.ListChannels(ctx, req) if err != nil { - predErr = fmt.Errorf("unable fetch node's channels: %v", err) - return false + return fmt.Errorf("unable fetch node's channels: %v", err) } for _, channel := range resp.Channels { 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 not found: %v", predErr) - } - - return nil + return fmt.Errorf("channel %s not found", chanPoint) + }, 15*time.Second) } // DumpLogs reads the current logs generated by the passed node, and returns