mirror of
https://github.com/getAlby/lndhub.go.git
synced 2025-12-23 15:44:51 +01:00
fix test with sleep
This commit is contained in:
@@ -98,25 +98,6 @@ func TestFinalizedInitializedPayments(t *testing.T) {
|
|||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
waitTimeout(&wg, time.Second * 3, t)
|
//wait a bit for payments to be processed
|
||||||
}
|
time.Sleep(time.Second)
|
||||||
|
|
||||||
// waitTimeout waits for the waitgroup for the specified max timeout.
|
|
||||||
// Returns true if waiting timed out.
|
|
||||||
func waitTimeout(wg *sync.WaitGroup, timeout time.Duration, t *testing.T) bool {
|
|
||||||
c := make(chan struct{})
|
|
||||||
go func() {
|
|
||||||
defer close(c)
|
|
||||||
wg.Wait()
|
|
||||||
}()
|
|
||||||
|
|
||||||
select {
|
|
||||||
case <-c:
|
|
||||||
return false // completed normally
|
|
||||||
|
|
||||||
case <-time.After(timeout):
|
|
||||||
t.Errorf("Waiting on waitgroup timed out during test")
|
|
||||||
|
|
||||||
return true // timed out
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user