MCPcopy Index your code
hub / github.com/coder/coder / echoOnce

Function echoOnce

agent/agent_test.go:4171–4187  ·  view source on GitHub ↗

echoOnce accepts a single connection, reads 4 bytes and echos them back

(t *testing.T, ll net.Listener)

Source from the content-addressed store, hash-verified

4169
4170// echoOnce accepts a single connection, reads 4 bytes and echos them back
4171func 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.
4190func requireEcho(t *testing.T, conn net.Conn) {

Calls 5

HelperMethod · 0.65
CloseMethod · 0.65
ReadMethod · 0.65
WriteMethod · 0.65
AcceptMethod · 0.45

Tested by

no test coverage detected