mirror of
https://github.com/getAlby/lndhub.go.git
synced 2025-12-22 23:25:26 +01:00
fix test with sleep
This commit is contained in:
@@ -98,25 +98,6 @@ func TestFinalizedInitializedPayments(t *testing.T) {
|
||||
wg.Done()
|
||||
}()
|
||||
|
||||
waitTimeout(&wg, time.Second * 3, t)
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
//wait a bit for payments to be processed
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user