mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
27 lines
386 B
Go
27 lines
386 B
Go
package contractcourt
|
|
|
|
import (
|
|
"os"
|
|
"runtime/pprof"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// timeout implements a test level timeout.
|
|
func timeout(t *testing.T) func() {
|
|
done := make(chan struct{})
|
|
go func() {
|
|
select {
|
|
case <-time.After(5 * time.Second):
|
|
pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
|
|
|
|
panic("test timeout")
|
|
case <-done:
|
|
}
|
|
}()
|
|
|
|
return func() {
|
|
close(done)
|
|
}
|
|
}
|