mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-13 11:09:23 +01:00
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:
parent
2e838abb3f
commit
0316523bb5
1 changed files with 4 additions and 0 deletions
|
@ -1035,8 +1035,12 @@ func (n *NetworkHarness) AssertChannelExists(ctx context.Context,
|
||||||
// several running lnd nodes. This function gives callers a way to assert that
|
// several running lnd nodes. This function gives callers a way to assert that
|
||||||
// some property is upheld within a particular time frame.
|
// some property is upheld within a particular time frame.
|
||||||
func WaitPredicate(pred func() bool, timeout time.Duration) error {
|
func WaitPredicate(pred func() bool, timeout time.Duration) error {
|
||||||
|
const pollInterval = 20 * time.Millisecond
|
||||||
|
|
||||||
exitTimer := time.After(timeout)
|
exitTimer := time.After(timeout)
|
||||||
for {
|
for {
|
||||||
|
<-time.After(pollInterval)
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-exitTimer:
|
case <-exitTimer:
|
||||||
return fmt.Errorf("predicate not satisfied after time out")
|
return fmt.Errorf("predicate not satisfied after time out")
|
||||||
|
|
Loading…
Add table
Reference in a new issue