add good practice to save space of empty struct -> size of 0

pull/69/head
Minh Doan 6 years ago
parent 028512ad81
commit fa869b6974
  1. 8
      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()
}

Loading…
Cancel
Save