(t *testing.T, serverReady *sync.WaitGroup, conn net.PacketConn)
| 96 | } |
| 97 | |
| 98 | func quicServer(t *testing.T, serverReady *sync.WaitGroup, conn net.PacketConn) { |
| 99 | ctx, cancel := context.WithCancel(context.Background()) |
| 100 | defer cancel() |
| 101 | |
| 102 | earlyListener, err := quic.Listen(conn, testTLSServerConfig, testQUICConfig) |
| 103 | require.NoError(t, err) |
| 104 | |
| 105 | serverReady.Done() |
| 106 | session, err := earlyListener.Accept(ctx) |
| 107 | require.NoError(t, err) |
| 108 | |
| 109 | var wg sync.WaitGroup |
| 110 | for exchange := 0; exchange < exchanges; exchange++ { |
| 111 | quicStream, err := session.OpenStreamSync(context.Background()) |
| 112 | require.NoError(t, err) |
| 113 | wg.Add(1) |
| 114 | |
| 115 | go func(iter int) { |
| 116 | defer wg.Done() |
| 117 | |
| 118 | log := zerolog.Nop() |
| 119 | stream := NewSafeStreamCloser(quicStream, 30*time.Second, &log) |
| 120 | defer stream.Close() |
| 121 | |
| 122 | // Do a bunch of round trips over this stream that should work. |
| 123 | for msg := 0; msg < msgsPerExchange; msg++ { |
| 124 | serverRoundTrip(t, stream, true) |
| 125 | } |
| 126 | // And one that won't work necessarily, but shouldn't break other streams in the session. |
| 127 | if iter%2 == 1 { |
| 128 | serverRoundTrip(t, stream, false) |
| 129 | } |
| 130 | }(exchange) |
| 131 | } |
| 132 | |
| 133 | wg.Wait() |
| 134 | } |
| 135 | |
| 136 | func clientRoundTrip(t *testing.T, stream io.ReadWriteCloser, mustWork bool) { |
| 137 | response := make([]byte, len(testMsg)) |
no test coverage detected