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.
This commit is contained in:
Johan T. Halseth 2018-06-11 15:58:23 +02:00
parent 2e838abb3f
commit 0316523bb5
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -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")