echoOnce accepts a single connection, reads 4 bytes and echos them back
(t *testing.T, ll net.Listener)
| 4169 | |
| 4170 | // echoOnce accepts a single connection, reads 4 bytes and echos them back |
| 4171 | func echoOnce(t *testing.T, ll net.Listener) { |
| 4172 | t.Helper() |
| 4173 | conn, err := ll.Accept() |
| 4174 | if err != nil { |
| 4175 | return |
| 4176 | } |
| 4177 | defer conn.Close() |
| 4178 | b := make([]byte, 4) |
| 4179 | _, err = conn.Read(b) |
| 4180 | if !assert.NoError(t, err) { |
| 4181 | return |
| 4182 | } |
| 4183 | _, err = conn.Write(b) |
| 4184 | if !assert.NoError(t, err) { |
| 4185 | return |
| 4186 | } |
| 4187 | } |
| 4188 | |
| 4189 | // requireEcho sends 4 bytes and requires the read response to match what was sent. |
| 4190 | func requireEcho(t *testing.T, conn net.Conn) { |
no test coverage detected