From 0316523bb5d1e6076c72554d53269e301a9037ff Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Mon, 11 Jun 2018 15:58:23 +0200 Subject: [PATCH] lntest/harness: add pollIntervall to WaitPredicate This commit adds a poll 20 ms interval to WaitPredicate, similar to what is done for WaitInvariant. This makes the predicate not being checked super-rapidly, potentially filling the logs with useless info over the wait predicate interval. --- lntest/harness.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lntest/harness.go b/lntest/harness.go index 600c7b02f..f53050092 100644 --- a/lntest/harness.go +++ b/lntest/harness.go @@ -1035,8 +1035,12 @@ func (n *NetworkHarness) AssertChannelExists(ctx context.Context, // several running lnd nodes. This function gives callers a way to assert that // some property is upheld within a particular time frame. func WaitPredicate(pred func() bool, timeout time.Duration) error { + const pollInterval = 20 * time.Millisecond + exitTimer := time.After(timeout) for { + <-time.After(pollInterval) + select { case <-exitTimer: return fmt.Errorf("predicate not satisfied after time out")