From 36c66c0e93992157fab2ca46740db2556f99d4f1 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 17 Aug 2016 16:38:35 -0700 Subject: [PATCH] host: add wait for handshake in proto preknowledge test --- p2p/host/basic/basic_host_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/p2p/host/basic/basic_host_test.go b/p2p/host/basic/basic_host_test.go index c52d927..5b56684 100644 --- a/p2p/host/basic/basic_host_test.go +++ b/p2p/host/basic/basic_host_test.go @@ -194,6 +194,9 @@ func TestHostProtoPreknowledge(t *testing.T) { defer h1.Close() defer h2.Close() + // wait for identify handshake to finish completely + time.Sleep(time.Millisecond * 20) + h1.SetStreamHandler("/foo", handler) s, err := h2.NewStream(ctx, h1.ID(), "/foo", "/bar", "/super") @@ -202,8 +205,8 @@ func TestHostProtoPreknowledge(t *testing.T) { } select { - case <-conn: - t.Fatal("shouldnt have gotten connection yet, we should have a lazy stream") + case p := <-conn: + t.Fatal("shouldnt have gotten connection yet, we should have a lazy stream: ", p) case <-time.After(time.Millisecond * 50): } -- GitLab