From fa869b6974f90789b5a9b8e5a66f83afd6340fc4 Mon Sep 17 00:00:00 2001 From: Minh Doan Date: Tue, 4 Sep 2018 16:22:20 -0700 Subject: [PATCH] add good practice to save space of empty struct -> size of 0 --- p2p/helper_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/p2p/helper_test.go b/p2p/helper_test.go index da0062b5f..388749b5d 100644 --- a/p2p/helper_test.go +++ b/p2p/helper_test.go @@ -6,10 +6,10 @@ import ( "testing" ) -func setUpTestServer(times int, t *testing.T, conCreated chan bool) { +func setUpTestServer(times int, t *testing.T, conCreated chan struct{}) { t.Parallel() ln, _ := net.Listen("tcp", ":8081") - conCreated <- true + conCreated <- struct{}{} conn, _ := ln.Accept() defer conn.Close() @@ -29,11 +29,12 @@ func setUpTestServer(times int, t *testing.T, conCreated chan bool) { } func TestNewNewNode(t *testing.T) { times := 100 - conCreated := make(chan bool) + conCreated := make(chan struct{}) go setUpTestServer(times, t, conCreated) <-conCreated conn, _ := net.Dial("tcp", "127.0.0.1:8081") + defer conn.Close() for times > 0 { times-- @@ -49,5 +50,4 @@ func TestNewNewNode(t *testing.T) { t.Error("did not receive expected message") } } - conn.Close() }