|
1 | 1 | package p2p |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "bytes" |
5 | 4 | "crypto/ecdsa" |
6 | | - "io" |
7 | 5 | "math/rand" |
8 | 6 | "net" |
9 | | - "sync" |
10 | 7 | "testing" |
11 | 8 | "time" |
12 | 9 |
|
@@ -121,45 +118,6 @@ func TestServerDial(t *testing.T) { |
121 | 118 | } |
122 | 119 | } |
123 | 120 |
|
124 | | -func TestServerBroadcast(t *testing.T) { |
125 | | - var connected sync.WaitGroup |
126 | | - srv := startTestServer(t, func(p *Peer) { |
127 | | - p.running = matchProtocols([]Protocol{discard}, []Cap{discard.cap()}, p.rw) |
128 | | - connected.Done() |
129 | | - }) |
130 | | - defer srv.Stop() |
131 | | - |
132 | | - // create a few peers |
133 | | - var conns = make([]net.Conn, 8) |
134 | | - connected.Add(len(conns)) |
135 | | - deadline := time.Now().Add(3 * time.Second) |
136 | | - dialer := &net.Dialer{Deadline: deadline} |
137 | | - for i := range conns { |
138 | | - conn, err := dialer.Dial("tcp", srv.ListenAddr) |
139 | | - if err != nil { |
140 | | - t.Fatalf("conn %d: dial error: %v", i, err) |
141 | | - } |
142 | | - defer conn.Close() |
143 | | - conn.SetDeadline(deadline) |
144 | | - conns[i] = conn |
145 | | - } |
146 | | - connected.Wait() |
147 | | - |
148 | | - // broadcast one message |
149 | | - srv.Broadcast("discard", 0, []string{"foo"}) |
150 | | - golden := unhex("66e94d166f0a2c3b884cfa59ca34") |
151 | | - |
152 | | - // check that the message has been written everywhere |
153 | | - for i, conn := range conns { |
154 | | - buf := make([]byte, len(golden)) |
155 | | - if _, err := io.ReadFull(conn, buf); err != nil { |
156 | | - t.Errorf("conn %d: read error: %v", i, err) |
157 | | - } else if !bytes.Equal(buf, golden) { |
158 | | - t.Errorf("conn %d: msg mismatch\ngot: %x\nwant: %x", i, buf, golden) |
159 | | - } |
160 | | - } |
161 | | -} |
162 | | - |
163 | 121 | // This test checks that connections are disconnected |
164 | 122 | // just after the encryption handshake when the server is |
165 | 123 | // at capacity. |
|
0 commit comments