mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-18 21:35:24 +01:00
lntest/wait: handle the case where the pred func hangs
This commit fixes a bug in the wait.NoError function. If the predicate function, f, passed to the NoError function would hang for the full timeout, then the `predErr` would remain nil and so a nil error would be returned from the function. This commit handles that case.
This commit is contained in:
parent
5330b3e414
commit
de961af5c6
@ -58,6 +58,13 @@ func NoError(f func() error, timeout time.Duration) error {
|
||||
// If f() doesn't succeed within the timeout, return the last
|
||||
// encountered error.
|
||||
if err := Predicate(pred, timeout); err != nil {
|
||||
// Handle the case where the passed in method, f, hangs for the
|
||||
// full timeout
|
||||
if predErr == nil {
|
||||
return fmt.Errorf("method did not return within the " +
|
||||
"timeout")
|
||||
}
|
||||
|
||||
return predErr
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user