From 1a7fac45514aa26fccb1dc7d8821146947d2e440 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 14 Oct 2014 17:46:11 -0700 Subject: [PATCH] make test fail instead of hang --- routing/dht/dht_test.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/routing/dht/dht_test.go b/routing/dht/dht_test.go index 9e8251a43..84f5f830e 100644 --- a/routing/dht/dht_test.go +++ b/routing/dht/dht_test.go @@ -431,6 +431,15 @@ func TestConnectCollision(t *testing.T) { done <- struct{}{} }() - <-done - <-done + timeout := time.After(time.Second * 5) + select { + case <-done: + case <-timeout: + t.Fatal("Timeout received!") + } + select { + case <-done: + case <-timeout: + t.Fatal("Timeout received!") + } }