1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Common utilities for Quic tests
7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_
8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_
13 #include "base/strings/string_piece.h"
14 #include "net/quic/congestion_control/loss_detection_interface.h"
15 #include "net/quic/congestion_control/send_algorithm_interface.h"
16 #include "net/quic/quic_ack_notifier.h"
17 #include "net/quic/quic_client_session_base.h"
18 #include "net/quic/quic_connection.h"
19 #include "net/quic/quic_dispatcher.h"
20 #include "net/quic/quic_framer.h"
21 #include "net/quic/quic_per_connection_packet_writer.h"
22 #include "net/quic/quic_sent_packet_manager.h"
23 #include "net/quic/quic_session.h"
24 #include "net/quic/test_tools/mock_clock.h"
25 #include "net/quic/test_tools/mock_random.h"
26 #include "net/spdy/spdy_framer.h"
27 #include "testing/gmock/include/gmock/gmock.h"
33 static const QuicConnectionId kTestConnectionId
= 42;
34 static const int kTestPort
= 123;
35 static const uint32 kInitialStreamFlowControlWindowForTest
=
37 static const uint32 kInitialSessionFlowControlWindowForTest
=
40 // Data stream IDs start at 5: the crypto stream is 1, headers stream is 3.
41 static const QuicStreamId kClientDataStreamId1
= 5;
42 static const QuicStreamId kClientDataStreamId2
= 7;
43 static const QuicStreamId kClientDataStreamId3
= 9;
44 static const QuicStreamId kClientDataStreamId4
= 11;
46 // Returns the test peer IP address.
47 IPAddressNumber
TestPeerIPAddress();
49 // Upper limit on versions we support.
50 QuicVersion
QuicVersionMax();
52 // Lower limit on versions we support.
53 QuicVersion
QuicVersionMin();
55 // Returns an address for 127.0.0.1.
56 IPAddressNumber
Loopback4();
58 // Returns an address for ::1.
59 IPAddressNumber
Loopback6();
61 void GenerateBody(std::string
* body
, int length
);
63 // Create an encrypted packet for testing.
64 QuicEncryptedPacket
* ConstructEncryptedPacket(
65 QuicConnectionId connection_id
,
68 QuicPacketSequenceNumber sequence_number
,
69 const std::string
& data
);
71 void CompareCharArraysWithHexError(const std::string
& description
,
75 const int expected_len
);
77 bool DecodeHexString(const base::StringPiece
& hex
, std::string
* bytes
);
79 // Returns the length of a QuicPacket that is capable of holding either a
80 // stream frame or a minimal ack frame. Sets |*payload_length| to the number
81 // of bytes of stream data that will fit in such a packet.
82 size_t GetPacketLengthForOneStream(
85 QuicSequenceNumberLength sequence_number_length
,
86 InFecGroup is_in_fec_group
,
87 size_t* payload_length
);
89 // Returns QuicConfig set to default values.
90 QuicConfig
DefaultQuicConfig();
92 // Returns a version vector consisting of |version|.
93 QuicVersionVector
SupportedVersions(QuicVersion version
);
95 // Testing convenience method to construct a QuicAckFrame with entropy_hash set
96 // to 0 and largest_observed from peer set to |largest_observed|.
97 QuicAckFrame
MakeAckFrame(QuicPacketSequenceNumber largest_observed
);
99 // Testing convenience method to construct a QuicAckFrame with |num_nack_ranges|
100 // nack ranges of width 1 packet, starting from |least_unacked|.
101 QuicAckFrame
MakeAckFrameWithNackRanges(size_t num_nack_ranges
,
102 QuicPacketSequenceNumber least_unacked
);
104 // Returns a SerializedPacket whose |packet| member is owned by the caller, and
105 // is populated with the fields in |header| and |frames|, or is NULL if the
106 // packet could not be created.
107 SerializedPacket
BuildUnsizedDataPacket(QuicFramer
* framer
,
108 const QuicPacketHeader
& header
,
109 const QuicFrames
& frames
);
111 template<typename SaveType
>
114 ValueRestore(SaveType
* name
, SaveType value
)
127 DISALLOW_COPY_AND_ASSIGN(ValueRestore
);
130 // Simple random number generator used to compute random numbers suitable
131 // for pseudo-randomly dropping packets in tests. It works by computing
132 // the sha1 hash of the current seed, and using the first 64 bits as
133 // the next random number, and the next seed.
136 SimpleRandom() : seed_(0) {}
138 // Returns a random number in the range [0, kuint64max].
141 void set_seed(uint64 seed
) { seed_
= seed
; }
146 DISALLOW_COPY_AND_ASSIGN(SimpleRandom
);
149 class MockFramerVisitor
: public QuicFramerVisitorInterface
{
152 virtual ~MockFramerVisitor();
154 MOCK_METHOD1(OnError
, void(QuicFramer
* framer
));
155 // The constructor sets this up to return false by default.
156 MOCK_METHOD1(OnProtocolVersionMismatch
, bool(QuicVersion version
));
157 MOCK_METHOD0(OnPacket
, void());
158 MOCK_METHOD1(OnPublicResetPacket
, void(const QuicPublicResetPacket
& header
));
159 MOCK_METHOD1(OnVersionNegotiationPacket
,
160 void(const QuicVersionNegotiationPacket
& packet
));
161 MOCK_METHOD0(OnRevivedPacket
, void());
162 // The constructor sets this up to return true by default.
163 MOCK_METHOD1(OnUnauthenticatedHeader
, bool(const QuicPacketHeader
& header
));
164 // The constructor sets this up to return true by default.
165 MOCK_METHOD1(OnUnauthenticatedPublicHeader
, bool(
166 const QuicPacketPublicHeader
& header
));
167 MOCK_METHOD1(OnDecryptedPacket
, void(EncryptionLevel level
));
168 MOCK_METHOD1(OnPacketHeader
, bool(const QuicPacketHeader
& header
));
169 MOCK_METHOD1(OnFecProtectedPayload
, void(base::StringPiece payload
));
170 MOCK_METHOD1(OnStreamFrame
, bool(const QuicStreamFrame
& frame
));
171 MOCK_METHOD1(OnAckFrame
, bool(const QuicAckFrame
& frame
));
172 MOCK_METHOD1(OnCongestionFeedbackFrame
,
173 bool(const QuicCongestionFeedbackFrame
& frame
));
174 MOCK_METHOD1(OnStopWaitingFrame
, bool(const QuicStopWaitingFrame
& frame
));
175 MOCK_METHOD1(OnPingFrame
, bool(const QuicPingFrame
& frame
));
176 MOCK_METHOD1(OnFecData
, void(const QuicFecData
& fec
));
177 MOCK_METHOD1(OnRstStreamFrame
, bool(const QuicRstStreamFrame
& frame
));
178 MOCK_METHOD1(OnConnectionCloseFrame
,
179 bool(const QuicConnectionCloseFrame
& frame
));
180 MOCK_METHOD1(OnGoAwayFrame
, bool(const QuicGoAwayFrame
& frame
));
181 MOCK_METHOD1(OnWindowUpdateFrame
, bool(const QuicWindowUpdateFrame
& frame
));
182 MOCK_METHOD1(OnBlockedFrame
, bool(const QuicBlockedFrame
& frame
));
183 MOCK_METHOD0(OnPacketComplete
, void());
186 DISALLOW_COPY_AND_ASSIGN(MockFramerVisitor
);
189 class NoOpFramerVisitor
: public QuicFramerVisitorInterface
{
191 NoOpFramerVisitor() {}
193 virtual void OnError(QuicFramer
* framer
) OVERRIDE
{}
194 virtual void OnPacket() OVERRIDE
{}
195 virtual void OnPublicResetPacket(
196 const QuicPublicResetPacket
& packet
) OVERRIDE
{}
197 virtual void OnVersionNegotiationPacket(
198 const QuicVersionNegotiationPacket
& packet
) OVERRIDE
{}
199 virtual void OnRevivedPacket() OVERRIDE
{}
200 virtual bool OnProtocolVersionMismatch(QuicVersion version
) OVERRIDE
;
201 virtual bool OnUnauthenticatedHeader(const QuicPacketHeader
& header
) OVERRIDE
;
202 virtual bool OnUnauthenticatedPublicHeader(
203 const QuicPacketPublicHeader
& header
) OVERRIDE
;
204 virtual void OnDecryptedPacket(EncryptionLevel level
) OVERRIDE
{}
205 virtual bool OnPacketHeader(const QuicPacketHeader
& header
) OVERRIDE
;
206 virtual void OnFecProtectedPayload(base::StringPiece payload
) OVERRIDE
{}
207 virtual bool OnStreamFrame(const QuicStreamFrame
& frame
) OVERRIDE
;
208 virtual bool OnAckFrame(const QuicAckFrame
& frame
) OVERRIDE
;
209 virtual bool OnCongestionFeedbackFrame(
210 const QuicCongestionFeedbackFrame
& frame
) OVERRIDE
;
211 virtual bool OnStopWaitingFrame(
212 const QuicStopWaitingFrame
& frame
) OVERRIDE
;
213 virtual bool OnPingFrame(const QuicPingFrame
& frame
) OVERRIDE
;
214 virtual void OnFecData(const QuicFecData
& fec
) OVERRIDE
{}
215 virtual bool OnRstStreamFrame(const QuicRstStreamFrame
& frame
) OVERRIDE
;
216 virtual bool OnConnectionCloseFrame(
217 const QuicConnectionCloseFrame
& frame
) OVERRIDE
;
218 virtual bool OnGoAwayFrame(const QuicGoAwayFrame
& frame
) OVERRIDE
;
219 virtual bool OnWindowUpdateFrame(const QuicWindowUpdateFrame
& frame
) OVERRIDE
;
220 virtual bool OnBlockedFrame(const QuicBlockedFrame
& frame
) OVERRIDE
;
221 virtual void OnPacketComplete() OVERRIDE
{}
224 DISALLOW_COPY_AND_ASSIGN(NoOpFramerVisitor
);
227 class MockConnectionVisitor
: public QuicConnectionVisitorInterface
{
229 MockConnectionVisitor();
230 virtual ~MockConnectionVisitor();
232 MOCK_METHOD1(OnStreamFrames
, void(const std::vector
<QuicStreamFrame
>& frame
));
233 MOCK_METHOD1(OnWindowUpdateFrames
,
234 void(const std::vector
<QuicWindowUpdateFrame
>& frame
));
235 MOCK_METHOD1(OnBlockedFrames
,
236 void(const std::vector
<QuicBlockedFrame
>& frame
));
237 MOCK_METHOD1(OnRstStream
, void(const QuicRstStreamFrame
& frame
));
238 MOCK_METHOD1(OnGoAway
, void(const QuicGoAwayFrame
& frame
));
239 MOCK_METHOD2(OnConnectionClosed
, void(QuicErrorCode error
, bool from_peer
));
240 MOCK_METHOD0(OnWriteBlocked
, void());
241 MOCK_METHOD0(OnCanWrite
, void());
242 MOCK_METHOD1(OnCongestionWindowChange
, void(QuicTime now
));
243 MOCK_CONST_METHOD0(WillingAndAbleToWrite
, bool());
244 MOCK_CONST_METHOD0(HasPendingHandshake
, bool());
245 MOCK_CONST_METHOD0(HasOpenDataStreams
, bool());
246 MOCK_METHOD1(OnSuccessfulVersionNegotiation
,
247 void(const QuicVersion
& version
));
248 MOCK_METHOD0(OnConfigNegotiated
, void());
251 DISALLOW_COPY_AND_ASSIGN(MockConnectionVisitor
);
254 class MockHelper
: public QuicConnectionHelperInterface
{
257 virtual ~MockHelper();
258 virtual const QuicClock
* GetClock() const OVERRIDE
;
259 virtual QuicRandom
* GetRandomGenerator() OVERRIDE
;
260 virtual QuicAlarm
* CreateAlarm(QuicAlarm::Delegate
* delegate
) OVERRIDE
;
261 void AdvanceTime(QuicTime::Delta delta
);
265 MockRandom random_generator_
;
267 DISALLOW_COPY_AND_ASSIGN(MockHelper
);
270 class MockConnection
: public QuicConnection
{
272 // Uses a MockHelper, ConnectionId of 42, and 127.0.0.1:123.
273 explicit MockConnection(bool is_server
);
275 // Uses a MockHelper, ConnectionId of 42.
276 MockConnection(IPEndPoint address
, bool is_server
);
278 // Uses a MockHelper, and 127.0.0.1:123
279 MockConnection(QuicConnectionId connection_id
, bool is_server
);
281 // Uses a Mock helper, ConnectionId of 42, and 127.0.0.1:123.
282 MockConnection(bool is_server
, const QuicVersionVector
& supported_versions
);
284 virtual ~MockConnection();
286 // If the constructor that uses a MockHelper has been used then this method
287 // will advance the time of the MockClock.
288 void AdvanceTime(QuicTime::Delta delta
);
290 MOCK_METHOD3(ProcessUdpPacket
, void(const IPEndPoint
& self_address
,
291 const IPEndPoint
& peer_address
,
292 const QuicEncryptedPacket
& packet
));
293 MOCK_METHOD1(SendConnectionClose
, void(QuicErrorCode error
));
294 MOCK_METHOD2(SendConnectionCloseWithDetails
, void(QuicErrorCode error
,
295 const string
& details
));
296 MOCK_METHOD2(SendConnectionClosePacket
, void(QuicErrorCode error
,
297 const string
& details
));
298 MOCK_METHOD3(SendRstStream
, void(QuicStreamId id
,
299 QuicRstStreamErrorCode error
,
300 QuicStreamOffset bytes_written
));
301 MOCK_METHOD3(SendGoAway
, void(QuicErrorCode error
,
302 QuicStreamId last_good_stream_id
,
303 const string
& reason
));
304 MOCK_METHOD1(SendBlocked
, void(QuicStreamId id
));
305 MOCK_METHOD2(SendWindowUpdate
, void(QuicStreamId id
,
306 QuicStreamOffset byte_offset
));
307 MOCK_METHOD0(OnCanWrite
, void());
309 void ProcessUdpPacketInternal(const IPEndPoint
& self_address
,
310 const IPEndPoint
& peer_address
,
311 const QuicEncryptedPacket
& packet
) {
312 QuicConnection::ProcessUdpPacket(self_address
, peer_address
, packet
);
315 virtual bool OnProtocolVersionMismatch(QuicVersion version
) OVERRIDE
{
320 scoped_ptr
<QuicConnectionHelperInterface
> helper_
;
322 DISALLOW_COPY_AND_ASSIGN(MockConnection
);
325 class PacketSavingConnection
: public MockConnection
{
327 explicit PacketSavingConnection(bool is_server
);
329 PacketSavingConnection(bool is_server
,
330 const QuicVersionVector
& supported_versions
);
332 virtual ~PacketSavingConnection();
334 virtual bool SendOrQueuePacket(EncryptionLevel level
,
335 const SerializedPacket
& packet
,
336 TransmissionType transmission_type
) OVERRIDE
;
338 std::vector
<QuicPacket
*> packets_
;
339 std::vector
<QuicEncryptedPacket
*> encrypted_packets_
;
342 DISALLOW_COPY_AND_ASSIGN(PacketSavingConnection
);
345 class MockSession
: public QuicSession
{
347 explicit MockSession(QuicConnection
* connection
);
348 virtual ~MockSession();
349 MOCK_METHOD2(OnConnectionClosed
, void(QuicErrorCode error
, bool from_peer
));
350 MOCK_METHOD1(CreateIncomingDataStream
, QuicDataStream
*(QuicStreamId id
));
351 MOCK_METHOD0(GetCryptoStream
, QuicCryptoStream
*());
352 MOCK_METHOD0(CreateOutgoingDataStream
, QuicDataStream
*());
353 MOCK_METHOD6(WritevData
,
354 QuicConsumedData(QuicStreamId id
,
355 const IOVector
& data
,
356 QuicStreamOffset offset
,
358 FecProtection fec_protection
,
359 QuicAckNotifier::DelegateInterface
*));
360 MOCK_METHOD2(OnStreamHeaders
, void(QuicStreamId stream_id
,
361 base::StringPiece headers_data
));
362 MOCK_METHOD2(OnStreamHeadersPriority
, void(QuicStreamId stream_id
,
363 QuicPriority priority
));
364 MOCK_METHOD3(OnStreamHeadersComplete
, void(QuicStreamId stream_id
,
367 MOCK_METHOD3(SendRstStream
, void(QuicStreamId stream_id
,
368 QuicRstStreamErrorCode error
,
369 QuicStreamOffset bytes_written
));
370 MOCK_METHOD0(IsCryptoHandshakeConfirmed
, bool());
372 using QuicSession::ActivateStream
;
375 DISALLOW_COPY_AND_ASSIGN(MockSession
);
378 class TestSession
: public QuicSession
{
380 TestSession(QuicConnection
* connection
, const QuicConfig
& config
);
381 virtual ~TestSession();
383 MOCK_METHOD1(CreateIncomingDataStream
, QuicDataStream
*(QuicStreamId id
));
384 MOCK_METHOD0(CreateOutgoingDataStream
, QuicDataStream
*());
386 void SetCryptoStream(QuicCryptoStream
* stream
);
388 virtual QuicCryptoStream
* GetCryptoStream() OVERRIDE
;
391 QuicCryptoStream
* crypto_stream_
;
393 DISALLOW_COPY_AND_ASSIGN(TestSession
);
396 class TestClientSession
: public QuicClientSessionBase
{
398 TestClientSession(QuicConnection
* connection
, const QuicConfig
& config
);
399 virtual ~TestClientSession();
401 // QuicClientSessionBase
402 MOCK_METHOD1(OnProofValid
,
403 void(const QuicCryptoClientConfig::CachedState
& cached
));
404 MOCK_METHOD1(OnProofVerifyDetailsAvailable
,
405 void(const ProofVerifyDetails
& verify_details
));
408 MOCK_METHOD1(CreateIncomingDataStream
, QuicDataStream
*(QuicStreamId id
));
409 MOCK_METHOD0(CreateOutgoingDataStream
, QuicDataStream
*());
411 void SetCryptoStream(QuicCryptoStream
* stream
);
413 virtual QuicCryptoStream
* GetCryptoStream() OVERRIDE
;
416 QuicCryptoStream
* crypto_stream_
;
418 DISALLOW_COPY_AND_ASSIGN(TestClientSession
);
421 class MockPacketWriter
: public QuicPacketWriter
{
424 virtual ~MockPacketWriter();
426 MOCK_METHOD4(WritePacket
,
427 WriteResult(const char* buffer
,
429 const IPAddressNumber
& self_address
,
430 const IPEndPoint
& peer_address
));
431 MOCK_CONST_METHOD0(IsWriteBlockedDataBuffered
, bool());
432 MOCK_CONST_METHOD0(IsWriteBlocked
, bool());
433 MOCK_METHOD0(SetWritable
, void());
436 DISALLOW_COPY_AND_ASSIGN(MockPacketWriter
);
439 class MockSendAlgorithm
: public SendAlgorithmInterface
{
442 virtual ~MockSendAlgorithm();
444 MOCK_METHOD2(SetFromConfig
, void(const QuicConfig
& config
, bool is_server
));
445 MOCK_METHOD1(SetMaxPacketSize
, void(QuicByteCount max_packet_size
));
446 MOCK_METHOD2(OnIncomingQuicCongestionFeedbackFrame
,
447 void(const QuicCongestionFeedbackFrame
&,
448 QuicTime feedback_receive_time
));
449 MOCK_METHOD4(OnCongestionEvent
, void(bool rtt_updated
,
450 QuicByteCount bytes_in_flight
,
451 const CongestionMap
& acked_packets
,
452 const CongestionMap
& lost_packets
));
453 MOCK_METHOD5(OnPacketSent
,
454 bool(QuicTime
, QuicByteCount
, QuicPacketSequenceNumber
,
455 QuicByteCount
, HasRetransmittableData
));
456 MOCK_METHOD1(OnRetransmissionTimeout
, void(bool));
457 MOCK_METHOD0(RevertRetransmissionTimeout
, void());
458 MOCK_CONST_METHOD3(TimeUntilSend
,
459 QuicTime::Delta(QuicTime now
,
460 QuicByteCount bytes_in_flight
,
461 HasRetransmittableData
));
462 MOCK_CONST_METHOD0(BandwidthEstimate
, QuicBandwidth(void));
463 MOCK_CONST_METHOD0(HasReliableBandwidthEstimate
, bool());
464 MOCK_METHOD1(OnRttUpdated
, void(QuicPacketSequenceNumber
));
465 MOCK_CONST_METHOD0(RetransmissionDelay
, QuicTime::Delta(void));
466 MOCK_CONST_METHOD0(GetCongestionWindow
, QuicByteCount());
467 MOCK_CONST_METHOD0(InSlowStart
, bool());
468 MOCK_CONST_METHOD0(InRecovery
, bool());
469 MOCK_CONST_METHOD0(GetSlowStartThreshold
, QuicByteCount());
470 MOCK_CONST_METHOD0(GetCongestionControlType
, CongestionControlType());
473 DISALLOW_COPY_AND_ASSIGN(MockSendAlgorithm
);
476 class MockLossAlgorithm
: public LossDetectionInterface
{
479 virtual ~MockLossAlgorithm();
481 MOCK_CONST_METHOD0(GetLossDetectionType
, LossDetectionType());
482 MOCK_METHOD4(DetectLostPackets
,
483 SequenceNumberSet(const QuicUnackedPacketMap
& unacked_packets
,
484 const QuicTime
& time
,
485 QuicPacketSequenceNumber largest_observed
,
486 const RttStats
& rtt_stats
));
487 MOCK_CONST_METHOD0(GetLossTimeout
, QuicTime());
490 DISALLOW_COPY_AND_ASSIGN(MockLossAlgorithm
);
493 class TestEntropyCalculator
:
494 public QuicReceivedEntropyHashCalculatorInterface
{
496 TestEntropyCalculator();
497 virtual ~TestEntropyCalculator();
499 virtual QuicPacketEntropyHash
EntropyHash(
500 QuicPacketSequenceNumber sequence_number
) const OVERRIDE
;
503 DISALLOW_COPY_AND_ASSIGN(TestEntropyCalculator
);
506 class MockEntropyCalculator
: public TestEntropyCalculator
{
508 MockEntropyCalculator();
509 virtual ~MockEntropyCalculator();
513 QuicPacketEntropyHash(QuicPacketSequenceNumber sequence_number
));
516 DISALLOW_COPY_AND_ASSIGN(MockEntropyCalculator
);
519 class MockAckNotifierDelegate
: public QuicAckNotifier::DelegateInterface
{
521 MockAckNotifierDelegate();
523 MOCK_METHOD5(OnAckNotification
, void(int num_original_packets
,
524 int num_original_bytes
,
525 int num_retransmitted_packets
,
526 int num_retransmitted_bytes
,
527 QuicTime::Delta delta_largest_observed
));
530 // Object is ref counted.
531 virtual ~MockAckNotifierDelegate();
534 DISALLOW_COPY_AND_ASSIGN(MockAckNotifierDelegate
);
537 class MockNetworkChangeVisitor
:
538 public QuicSentPacketManager::NetworkChangeVisitor
{
540 MockNetworkChangeVisitor();
541 virtual ~MockNetworkChangeVisitor();
543 MOCK_METHOD1(OnCongestionWindowChange
, void(QuicByteCount
));
546 DISALLOW_COPY_AND_ASSIGN(MockNetworkChangeVisitor
);
549 // Creates per-connection packet writers that register themselves with the
550 // TestWriterFactory on each write so that TestWriterFactory::OnPacketSent can
551 // be routed to the appropriate QuicConnection.
552 class TestWriterFactory
: public QuicDispatcher::PacketWriterFactory
{
555 virtual ~TestWriterFactory();
557 virtual QuicPacketWriter
* Create(QuicServerPacketWriter
* writer
,
558 QuicConnection
* connection
) OVERRIDE
;
560 // Calls OnPacketSent on the last QuicConnection to write through one of the
561 // packet writers created by this factory.
562 void OnPacketSent(WriteResult result
);
565 class PerConnectionPacketWriter
: public QuicPerConnectionPacketWriter
{
567 PerConnectionPacketWriter(TestWriterFactory
* factory
,
568 QuicServerPacketWriter
* writer
,
569 QuicConnection
* connection
);
570 virtual ~PerConnectionPacketWriter();
572 virtual WriteResult
WritePacket(
575 const IPAddressNumber
& self_address
,
576 const IPEndPoint
& peer_address
) OVERRIDE
;
579 TestWriterFactory
* factory_
;
582 // If an asynchronous write is happening and |writer| gets deleted, this
583 // clears the pointer to it to prevent use-after-free.
584 void Unregister(PerConnectionPacketWriter
* writer
);
586 PerConnectionPacketWriter
* current_writer_
;
592 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_