blob: e9ba302eff0c3446999f427d8cb65079ab47a1b5 [file] [log] [blame]
[email protected]8b37a092012-10-18 21:53:491// 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.
4
5#include "net/quic/test_tools/quic_test_utils.h"
[email protected]9c0b1352012-11-04 00:03:276
[email protected]a5b98172014-06-18 07:01:597#include "base/sha1.h"
[email protected]701bc892013-01-17 04:51:548#include "base/stl_util.h"
[email protected]b12764d2013-12-02 22:28:309#include "base/strings/string_number_conversions.h"
[email protected]8b37a092012-10-18 21:53:4910#include "net/quic/crypto/crypto_framer.h"
[email protected]6f54ab32013-03-02 17:43:3511#include "net/quic/crypto/crypto_handshake.h"
[email protected]872edd9e2013-01-16 08:51:1512#include "net/quic/crypto/crypto_utils.h"
[email protected]5351cc4b2013-03-03 07:22:4113#include "net/quic/crypto/null_encrypter.h"
[email protected]4df69842013-02-27 06:32:1614#include "net/quic/crypto/quic_decrypter.h"
15#include "net/quic/crypto/quic_encrypter.h"
rtenneti16a20772015-02-17 18:58:4816#include "net/quic/quic_data_writer.h"
[email protected]a57e0272013-04-26 07:31:4717#include "net/quic/quic_framer.h"
[email protected]5351cc4b2013-03-03 07:22:4118#include "net/quic/quic_packet_creator.h"
[email protected]79d13dcb2014-02-05 07:23:1319#include "net/quic/quic_utils.h"
rtennetid39bd762015-06-12 01:05:5220#include "net/quic/test_tools/crypto_test_utils.h"
[email protected]cbd731e2013-10-24 00:20:3921#include "net/quic/test_tools/quic_connection_peer.h"
[email protected]c244c5a12013-05-07 20:55:0422#include "net/spdy/spdy_frame_builder.h"
rchc99f380c2015-03-26 19:50:5623#include "net/tools/quic/quic_per_connection_packet_writer.h"
[email protected]8b37a092012-10-18 21:53:4924
[email protected]c244c5a12013-05-07 20:55:0425using base::StringPiece;
[email protected]8b37a092012-10-18 21:53:4926using std::max;
27using std::min;
28using std::string;
rchc0815442015-04-18 13:29:4629using testing::Invoke;
[email protected]bc356fe2014-06-19 11:14:1430using testing::_;
[email protected]8b37a092012-10-18 21:53:4931
32namespace net {
33namespace test {
[email protected]8b37a092012-10-18 21:53:4934
rtennetia004d332015-08-28 06:44:5735QuicAckFrame MakeAckFrame(QuicPacketNumber largest_observed) {
[email protected]fb35b0a2014-04-15 21:06:4936 QuicAckFrame ack;
[email protected]310d37b2014-08-02 06:15:3737 ack.largest_observed = largest_observed;
38 ack.entropy_hash = 0;
[email protected]fb35b0a2014-04-15 21:06:4939 return ack;
40}
41
rtennetia004d332015-08-28 06:44:5742QuicAckFrame MakeAckFrameWithNackRanges(size_t num_nack_ranges,
43 QuicPacketNumber least_unacked) {
[email protected]310d37b2014-08-02 06:15:3744 QuicAckFrame ack = MakeAckFrame(2 * num_nack_ranges + least_unacked);
[email protected]aa7e4ef2014-05-28 03:53:1545 // Add enough missing packets to get num_nack_ranges nack ranges.
rtennetia004d332015-08-28 06:44:5746 for (QuicPacketNumber i = 1; i < 2 * num_nack_ranges; i += 2) {
rtenneti493d90ef2015-09-14 04:43:1147 ack.missing_packets.Add(least_unacked + i);
[email protected]aa7e4ef2014-05-28 03:53:1548 }
49 return ack;
50}
51
rtennetib6ac61a52015-02-11 20:20:5252QuicPacket* BuildUnsizedDataPacket(QuicFramer* framer,
53 const QuicPacketHeader& header,
54 const QuicFrames& frames) {
[email protected]9cda5fd2014-06-03 10:20:2855 const size_t max_plaintext_size = framer->GetMaxPlaintextSize(kMaxPacketSize);
56 size_t packet_size = GetPacketHeaderSize(header);
57 for (size_t i = 0; i < frames.size(); ++i) {
58 DCHECK_LE(packet_size, max_plaintext_size);
59 bool first_frame = i == 0;
60 bool last_frame = i == frames.size() - 1;
61 const size_t frame_size = framer->GetSerializedFrameLength(
62 frames[i], max_plaintext_size - packet_size, first_frame, last_frame,
rtennetia004d332015-08-28 06:44:5763 header.is_in_fec_group, header.public_header.packet_number_length);
[email protected]9cda5fd2014-06-03 10:20:2864 DCHECK(frame_size);
65 packet_size += frame_size;
66 }
rtenneti16a20772015-02-17 18:58:4867 return BuildUnsizedDataPacket(framer, header, frames, packet_size);
68}
69
70QuicPacket* BuildUnsizedDataPacket(QuicFramer* framer,
71 const QuicPacketHeader& header,
72 const QuicFrames& frames,
73 size_t packet_size) {
74 char* buffer = new char[packet_size];
alyssarc39b80f2015-10-22 17:13:5875 size_t length = framer->BuildDataPacket(header, frames, buffer, packet_size);
76 DCHECK_NE(0u, length);
77 // Re-construct the data packet with data ownership.
78 return new QuicPacket(buffer, length, /* owns_buffer */ true,
rtenneti16a20772015-02-17 18:58:4879 header.public_header.connection_id_length,
80 header.public_header.version_flag,
rchcaec4242016-01-22 20:49:5281 header.public_header.multipath_flag,
rtennetia004d332015-08-28 06:44:5782 header.public_header.packet_number_length);
[email protected]9cda5fd2014-06-03 10:20:2883}
84
Avi Drissman13fc8932015-12-20 04:40:4685uint64_t SimpleRandom::RandUint64() {
[email protected]a5b98172014-06-18 07:01:5986 unsigned char hash[base::kSHA1Length];
87 base::SHA1HashBytes(reinterpret_cast<unsigned char*>(&seed_), sizeof(seed_),
88 hash);
89 memcpy(&seed_, hash, sizeof(seed_));
90 return seed_;
91}
92
[email protected]8b37a092012-10-18 21:53:4993MockFramerVisitor::MockFramerVisitor() {
94 // By default, we want to accept packets.
[email protected]14e8106c2013-03-14 16:25:3395 ON_CALL(*this, OnProtocolVersionMismatch(_))
96 .WillByDefault(testing::Return(false));
97
98 // By default, we want to accept packets.
[email protected]ec86d5462013-11-17 16:04:4999 ON_CALL(*this, OnUnauthenticatedHeader(_))
100 .WillByDefault(testing::Return(true));
101
[email protected]066d8182014-01-04 02:02:45102 ON_CALL(*this, OnUnauthenticatedPublicHeader(_))
103 .WillByDefault(testing::Return(true));
104
rjshaded5ced072015-12-18 19:26:02105 ON_CALL(*this, OnPacketHeader(_)).WillByDefault(testing::Return(true));
[email protected]a57e0272013-04-26 07:31:47106
rjshaded5ced072015-12-18 19:26:02107 ON_CALL(*this, OnStreamFrame(_)).WillByDefault(testing::Return(true));
[email protected]a57e0272013-04-26 07:31:47108
rjshaded5ced072015-12-18 19:26:02109 ON_CALL(*this, OnAckFrame(_)).WillByDefault(testing::Return(true));
[email protected]a57e0272013-04-26 07:31:47110
rjshaded5ced072015-12-18 19:26:02111 ON_CALL(*this, OnStopWaitingFrame(_)).WillByDefault(testing::Return(true));
[email protected]93dd91f2014-02-27 00:09:03112
rjshaded5ced072015-12-18 19:26:02113 ON_CALL(*this, OnPingFrame(_)).WillByDefault(testing::Return(true));
[email protected]d8c522112014-04-23 09:23:25114
rjshaded5ced072015-12-18 19:26:02115 ON_CALL(*this, OnRstStreamFrame(_)).WillByDefault(testing::Return(true));
[email protected]a57e0272013-04-26 07:31:47116
117 ON_CALL(*this, OnConnectionCloseFrame(_))
118 .WillByDefault(testing::Return(true));
119
rjshaded5ced072015-12-18 19:26:02120 ON_CALL(*this, OnGoAwayFrame(_)).WillByDefault(testing::Return(true));
[email protected]8b37a092012-10-18 21:53:49121}
122
rtenneti021e8822015-10-18 23:59:57123MockFramerVisitor::~MockFramerVisitor() {}
[email protected]8b37a092012-10-18 21:53:49124
[email protected]48878092013-07-26 14:51:56125bool NoOpFramerVisitor::OnProtocolVersionMismatch(QuicVersion version) {
[email protected]14e8106c2013-03-14 16:25:33126 return false;
127}
128
[email protected]066d8182014-01-04 02:02:45129bool NoOpFramerVisitor::OnUnauthenticatedPublicHeader(
130 const QuicPacketPublicHeader& header) {
131 return true;
132}
133
[email protected]ec86d5462013-11-17 16:04:49134bool NoOpFramerVisitor::OnUnauthenticatedHeader(
135 const QuicPacketHeader& header) {
136 return true;
137}
138
[email protected]8b37a092012-10-18 21:53:49139bool NoOpFramerVisitor::OnPacketHeader(const QuicPacketHeader& header) {
140 return true;
141}
142
[email protected]a57e0272013-04-26 07:31:47143bool NoOpFramerVisitor::OnStreamFrame(const QuicStreamFrame& frame) {
144 return true;
145}
146
147bool NoOpFramerVisitor::OnAckFrame(const QuicAckFrame& frame) {
148 return true;
149}
150
rjshaded5ced072015-12-18 19:26:02151bool NoOpFramerVisitor::OnStopWaitingFrame(const QuicStopWaitingFrame& frame) {
[email protected]93dd91f2014-02-27 00:09:03152 return true;
153}
154
[email protected]d8c522112014-04-23 09:23:25155bool NoOpFramerVisitor::OnPingFrame(const QuicPingFrame& frame) {
156 return true;
157}
158
rjshaded5ced072015-12-18 19:26:02159bool NoOpFramerVisitor::OnRstStreamFrame(const QuicRstStreamFrame& frame) {
[email protected]a57e0272013-04-26 07:31:47160 return true;
161}
162
163bool NoOpFramerVisitor::OnConnectionCloseFrame(
164 const QuicConnectionCloseFrame& frame) {
165 return true;
166}
167
168bool NoOpFramerVisitor::OnGoAwayFrame(const QuicGoAwayFrame& frame) {
169 return true;
170}
171
[email protected]cb23a922014-02-20 17:42:38172bool NoOpFramerVisitor::OnWindowUpdateFrame(
173 const QuicWindowUpdateFrame& frame) {
174 return true;
175}
176
177bool NoOpFramerVisitor::OnBlockedFrame(const QuicBlockedFrame& frame) {
178 return true;
179}
180
rchcaec4242016-01-22 20:49:52181bool NoOpFramerVisitor::OnPathCloseFrame(const QuicPathCloseFrame& frame) {
182 return true;
183}
184
rtenneti021e8822015-10-18 23:59:57185MockConnectionVisitor::MockConnectionVisitor() {}
[email protected]8d659e22013-01-19 04:26:10186
rtenneti021e8822015-10-18 23:59:57187MockConnectionVisitor::~MockConnectionVisitor() {}
[email protected]8d659e22013-01-19 04:26:10188
rch99b644c2015-11-04 05:25:28189MockConnectionHelper::MockConnectionHelper() {}
[email protected]9c0b1352012-11-04 00:03:27190
rch99b644c2015-11-04 05:25:28191MockConnectionHelper::~MockConnectionHelper() {}
[email protected]9c0b1352012-11-04 00:03:27192
rch99b644c2015-11-04 05:25:28193const QuicClock* MockConnectionHelper::GetClock() const {
[email protected]9c0b1352012-11-04 00:03:27194 return &clock_;
195}
196
rch99b644c2015-11-04 05:25:28197QuicRandom* MockConnectionHelper::GetRandomGenerator() {
[email protected]9558c5d32012-12-22 00:08:14198 return &random_generator_;
199}
200
rch99b644c2015-11-04 05:25:28201QuicAlarm* MockConnectionHelper::CreateAlarm(QuicAlarm::Delegate* delegate) {
jdorfman4ea54a22016-01-21 22:12:50202 return new MockConnectionHelper::TestAlarm(
203 QuicArenaScopedPtr<QuicAlarm::Delegate>(delegate));
204}
205
206QuicArenaScopedPtr<QuicAlarm> MockConnectionHelper::CreateAlarm(
207 QuicArenaScopedPtr<QuicAlarm::Delegate> delegate,
208 QuicConnectionArena* arena) {
209 if (arena != nullptr) {
210 return arena->New<MockConnectionHelper::TestAlarm>(std::move(delegate));
211 } else {
212 return QuicArenaScopedPtr<MockConnectionHelper::TestAlarm>(
213 new TestAlarm(std::move(delegate)));
214 }
[email protected]965dbe62013-08-09 21:34:31215}
216
jdorfman5a606722016-01-04 17:41:29217QuicBufferAllocator* MockConnectionHelper::GetBufferAllocator() {
218 return &buffer_allocator_;
219}
220
rch99b644c2015-11-04 05:25:28221void MockConnectionHelper::AdvanceTime(QuicTime::Delta delta) {
[email protected]fe053f92013-04-23 20:18:55222 clock_.AdvanceTime(delta);
223}
224
rch99b644c2015-11-04 05:25:28225MockConnection::MockConnection(MockConnectionHelper* helper,
226 Perspective perspective)
rchc0815442015-04-18 13:29:46227 : MockConnection(kTestConnectionId,
rtenneti8696cf92014-11-14 21:12:12228 IPEndPoint(TestPeerIPAddress(), kTestPort),
rtenneti8a4a0732015-10-18 00:45:51229 helper,
rtenneti6f48aa92015-03-16 02:18:48230 perspective,
rtenneti8a4a0732015-10-18 00:45:51231 QuicSupportedVersions()) {}
[email protected]c05a6d222013-12-16 19:42:03232
rtenneti8a4a0732015-10-18 00:45:51233MockConnection::MockConnection(IPEndPoint address,
rch99b644c2015-11-04 05:25:28234 MockConnectionHelper* helper,
rtenneti8a4a0732015-10-18 00:45:51235 Perspective perspective)
rchc0815442015-04-18 13:29:46236 : MockConnection(kTestConnectionId,
rtenneti6f48aa92015-03-16 02:18:48237 address,
rtenneti8a4a0732015-10-18 00:45:51238 helper,
rtenneti6f48aa92015-03-16 02:18:48239 perspective,
rtenneti8a4a0732015-10-18 00:45:51240 QuicSupportedVersions()) {}
[email protected]044ac2b2012-11-13 21:41:06241
[email protected]3aa9ca72014-02-27 19:39:43242MockConnection::MockConnection(QuicConnectionId connection_id,
rch99b644c2015-11-04 05:25:28243 MockConnectionHelper* helper,
rtenneti6f48aa92015-03-16 02:18:48244 Perspective perspective)
rchc0815442015-04-18 13:29:46245 : MockConnection(connection_id,
rtennetifb3fa6c2015-03-16 23:04:55246 IPEndPoint(TestPeerIPAddress(), kTestPort),
rtenneti8a4a0732015-10-18 00:45:51247 helper,
rchc0815442015-04-18 13:29:46248 perspective,
rtenneti8a4a0732015-10-18 00:45:51249 QuicSupportedVersions()) {}
rchc0815442015-04-18 13:29:46250
rch99b644c2015-11-04 05:25:28251MockConnection::MockConnection(MockConnectionHelper* helper,
rtenneti8a4a0732015-10-18 00:45:51252 Perspective perspective,
rchc0815442015-04-18 13:29:46253 const QuicVersionVector& supported_versions)
254 : MockConnection(kTestConnectionId,
255 IPEndPoint(TestPeerIPAddress(), kTestPort),
rtenneti8a4a0732015-10-18 00:45:51256 helper,
rchc0815442015-04-18 13:29:46257 perspective,
rtenneti8a4a0732015-10-18 00:45:51258 supported_versions) {}
rchc0815442015-04-18 13:29:46259
260MockConnection::MockConnection(QuicConnectionId connection_id,
261 IPEndPoint address,
rch99b644c2015-11-04 05:25:28262 MockConnectionHelper* helper,
rchc0815442015-04-18 13:29:46263 Perspective perspective,
rchc0815442015-04-18 13:29:46264 const QuicVersionVector& supported_versions)
265 : QuicConnection(connection_id,
266 address,
rtenneti8a4a0732015-10-18 00:45:51267 helper,
jdorfman90d185f32016-01-15 13:22:47268 new testing::NiceMock<MockPacketWriter>(),
rtennetifb3fa6c2015-03-16 23:04:55269 /* owns_writer= */ true,
270 perspective,
rtenneti8a4a0732015-10-18 00:45:51271 supported_versions) {
rchc0815442015-04-18 13:29:46272 ON_CALL(*this, OnError(_))
273 .WillByDefault(
274 Invoke(this, &PacketSavingConnection::QuicConnection_OnError));
[email protected]4d640792013-12-18 22:21:08275}
276
rtenneti021e8822015-10-18 23:59:57277MockConnection::~MockConnection() {}
[email protected]044ac2b2012-11-13 21:41:06278
[email protected]fe053f92013-04-23 20:18:55279void MockConnection::AdvanceTime(QuicTime::Delta delta) {
rch99b644c2015-11-04 05:25:28280 static_cast<MockConnectionHelper*>(helper())->AdvanceTime(delta);
[email protected]fe053f92013-04-23 20:18:55281}
282
rch99b644c2015-11-04 05:25:28283PacketSavingConnection::PacketSavingConnection(MockConnectionHelper* helper,
rtenneti8a4a0732015-10-18 00:45:51284 Perspective perspective)
285 : MockConnection(helper, perspective) {}
[email protected]044ac2b2012-11-13 21:41:06286
[email protected]4d640792013-12-18 22:21:08287PacketSavingConnection::PacketSavingConnection(
rch99b644c2015-11-04 05:25:28288 MockConnectionHelper* helper,
rtenneti6f48aa92015-03-16 02:18:48289 Perspective perspective,
[email protected]4d640792013-12-18 22:21:08290 const QuicVersionVector& supported_versions)
rtenneti8a4a0732015-10-18 00:45:51291 : MockConnection(helper, perspective, supported_versions) {}
[email protected]4d640792013-12-18 22:21:08292
[email protected]044ac2b2012-11-13 21:41:06293PacketSavingConnection::~PacketSavingConnection() {
[email protected]2532de12013-05-09 12:29:33294 STLDeleteElements(&encrypted_packets_);
[email protected]044ac2b2012-11-13 21:41:06295}
296
zhongyi4a9d27b2016-01-12 20:08:31297void PacketSavingConnection::SendOrQueuePacket(SerializedPacket* packet) {
298 if (!packet->packet->owns_buffer()) {
299 scoped_ptr<QuicEncryptedPacket> encrypted_deleter(packet->packet);
300 packet->packet = packet->packet->Clone();
rtennetie0ee6eb2015-05-01 00:55:09301 }
zhongyi4a9d27b2016-01-12 20:08:31302 encrypted_packets_.push_back(packet->packet);
rtenneti31e9fd62014-09-16 05:22:15303 // Transfer ownership of the packet to the SentPacketManager and the
304 // ack notifier to the AckNotifierManager.
zhongyi4a9d27b2016-01-12 20:08:31305 sent_packet_manager_.OnPacketSent(packet, 0, QuicTime::Zero(), 1000,
306 NOT_RETRANSMISSION,
rjshaded5ced072015-12-18 19:26:02307 HAS_RETRANSMITTABLE_DATA);
[email protected]044ac2b2012-11-13 21:41:06308}
309
rtennetib865eb82015-06-17 20:21:46310MockQuicSpdySession::MockQuicSpdySession(QuicConnection* connection)
311 : QuicSpdySession(connection, DefaultQuicConfig()) {
rtennetid39bd762015-06-12 01:05:52312 crypto_stream_.reset(new QuicCryptoStream(this));
313 Initialize();
[email protected]bbb10072014-06-13 07:41:59314 ON_CALL(*this, WritevData(_, _, _, _, _, _))
[email protected]cff7b7b2013-01-11 08:49:07315 .WillByDefault(testing::Return(QuicConsumedData(0, false)));
[email protected]044ac2b2012-11-13 21:41:06316}
317
rtenneti021e8822015-10-18 23:59:57318MockQuicSpdySession::~MockQuicSpdySession() {}
[email protected]044ac2b2012-11-13 21:41:06319
jokulik2324d282015-12-08 21:42:57320// static
321QuicConsumedData MockQuicSpdySession::ConsumeAllData(
322 QuicStreamId /*id*/,
323 const QuicIOVector& data,
324 QuicStreamOffset /*offset*/,
325 bool fin,
326 FecProtection /*fec_protection*/,
327 QuicAckListenerInterface* /*ack_notifier_delegate*/) {
328 return QuicConsumedData(data.total_length, fin);
329}
330
rtennetib865eb82015-06-17 20:21:46331TestQuicSpdyServerSession::TestQuicSpdyServerSession(
rtennetid39bd762015-06-12 01:05:52332 QuicConnection* connection,
333 const QuicConfig& config,
334 const QuicCryptoServerConfig* crypto_config)
jokulikc971baf92016-01-06 00:36:39335 : QuicServerSessionBase(config, connection, &visitor_, crypto_config) {
rtennetid39bd762015-06-12 01:05:52336 Initialize();
[email protected]ccb34212014-07-18 09:27:50337}
[email protected]2532de12013-05-09 12:29:33338
rtenneti021e8822015-10-18 23:59:57339TestQuicSpdyServerSession::~TestQuicSpdyServerSession() {}
[email protected]2532de12013-05-09 12:29:33340
jokulikc971baf92016-01-06 00:36:39341QuicCryptoServerStreamBase*
342TestQuicSpdyServerSession::CreateQuicCryptoServerStream(
343 const QuicCryptoServerConfig* crypto_config) {
344 return new QuicCryptoServerStream(crypto_config, this);
345}
346
rtennetib865eb82015-06-17 20:21:46347QuicCryptoServerStream* TestQuicSpdyServerSession::GetCryptoStream() {
zhongyib8677022015-12-01 05:51:30348 return static_cast<QuicCryptoServerStream*>(
jokulikc971baf92016-01-06 00:36:39349 QuicServerSessionBase::GetCryptoStream());
[email protected]2532de12013-05-09 12:29:33350}
351
rtennetib865eb82015-06-17 20:21:46352TestQuicSpdyClientSession::TestQuicSpdyClientSession(
353 QuicConnection* connection,
354 const QuicConfig& config,
355 const QuicServerId& server_id,
356 QuicCryptoClientConfig* crypto_config)
jric533399b2016-01-29 07:36:01357 : QuicClientSessionBase(connection, &promised_by_url_, config) {
rtennetid39bd762015-06-12 01:05:52358 crypto_stream_.reset(new QuicCryptoClientStream(
359 server_id, this, CryptoTestUtils::ProofVerifyContextForTesting(),
360 crypto_config));
361 Initialize();
[email protected]90f62f092014-03-24 02:41:23362}
363
rtenneti021e8822015-10-18 23:59:57364TestQuicSpdyClientSession::~TestQuicSpdyClientSession() {}
[email protected]90f62f092014-03-24 02:41:23365
rtennetib865eb82015-06-17 20:21:46366QuicCryptoClientStream* TestQuicSpdyClientSession::GetCryptoStream() {
rtennetid39bd762015-06-12 01:05:52367 return crypto_stream_.get();
rtennetia2ea9162015-05-15 19:26:44368}
369
[email protected]cbd731e2013-10-24 00:20:39370MockPacketWriter::MockPacketWriter() {
rtenneti493d90ef2015-09-14 04:43:11371 ON_CALL(*this, GetMaxPacketSize(_))
372 .WillByDefault(testing::Return(kMaxPacketSize));
[email protected]cbd731e2013-10-24 00:20:39373}
374
rtenneti021e8822015-10-18 23:59:57375MockPacketWriter::~MockPacketWriter() {}
[email protected]cbd731e2013-10-24 00:20:39376
rtenneti021e8822015-10-18 23:59:57377MockSendAlgorithm::MockSendAlgorithm() {}
[email protected]8d659e22013-01-19 04:26:10378
rtenneti021e8822015-10-18 23:59:57379MockSendAlgorithm::~MockSendAlgorithm() {}
[email protected]8d659e22013-01-19 04:26:10380
rtenneti021e8822015-10-18 23:59:57381MockLossAlgorithm::MockLossAlgorithm() {}
[email protected]3aa9ca72014-02-27 19:39:43382
rtenneti021e8822015-10-18 23:59:57383MockLossAlgorithm::~MockLossAlgorithm() {}
[email protected]3aa9ca72014-02-27 19:39:43384
ckrasicea295fe2015-10-31 05:03:27385MockAckListener::MockAckListener() {}
[email protected]97cf3022013-09-05 14:30:16386
ckrasicea295fe2015-10-31 05:03:27387MockAckListener::~MockAckListener() {}
[email protected]97cf3022013-09-05 14:30:16388
rtenneti021e8822015-10-18 23:59:57389MockNetworkChangeVisitor::MockNetworkChangeVisitor() {}
[email protected]a692ad9d2014-07-18 21:35:24390
rtenneti021e8822015-10-18 23:59:57391MockNetworkChangeVisitor::~MockNetworkChangeVisitor() {}
[email protected]a692ad9d2014-07-18 21:35:24392
[email protected]8b37a092012-10-18 21:53:49393namespace {
394
rjshaded5ced072015-12-18 19:26:02395string HexDumpWithMarks(const char* data,
396 int length,
397 const bool* marks,
398 int mark_length) {
[email protected]8b37a092012-10-18 21:53:49399 static const char kHexChars[] = "0123456789abcdef";
400 static const int kColumns = 4;
401
402 const int kSizeLimit = 1024;
403 if (length > kSizeLimit || mark_length > kSizeLimit) {
404 LOG(ERROR) << "Only dumping first " << kSizeLimit << " bytes.";
405 length = min(length, kSizeLimit);
406 mark_length = min(mark_length, kSizeLimit);
407 }
408
409 string hex;
rjshaded5ced072015-12-18 19:26:02410 for (const char *row = data; length > 0;
[email protected]8b37a092012-10-18 21:53:49411 row += kColumns, length -= kColumns) {
rjshaded5ced072015-12-18 19:26:02412 for (const char* p = row; p < row + 4; ++p) {
[email protected]8b37a092012-10-18 21:53:49413 if (p < row + length) {
414 const bool mark =
415 (marks && (p - data) < mark_length && marks[p - data]);
416 hex += mark ? '*' : ' ';
417 hex += kHexChars[(*p & 0xf0) >> 4];
418 hex += kHexChars[*p & 0x0f];
419 hex += mark ? '*' : ' ';
420 } else {
421 hex += " ";
422 }
423 }
424 hex = hex + " ";
425
rtenneti6f48aa92015-03-16 02:18:48426 for (const char* p = row; p < row + 4 && p < row + length; ++p) {
[email protected]8b37a092012-10-18 21:53:49427 hex += (*p >= 0x20 && *p <= 0x7f) ? (*p) : '.';
rtenneti6f48aa92015-03-16 02:18:48428 }
[email protected]8b37a092012-10-18 21:53:49429
430 hex = hex + '\n';
431 }
432 return hex;
433}
434
435} // namespace
436
rjshaded5ced072015-12-18 19:26:02437IPAddressNumber TestPeerIPAddress() {
438 return Loopback4();
439}
[email protected]300ccd52014-01-25 08:00:19440
rjshaded5ced072015-12-18 19:26:02441QuicVersion QuicVersionMax() {
442 return QuicSupportedVersions().front();
443}
[email protected]b007e632013-10-28 08:39:25444
rjshaded5ced072015-12-18 19:26:02445QuicVersion QuicVersionMin() {
446 return QuicSupportedVersions().back();
447}
[email protected]b007e632013-10-28 08:39:25448
[email protected]c05a6d222013-12-16 19:42:03449IPAddressNumber Loopback4() {
[email protected]300ccd52014-01-25 08:00:19450 IPAddressNumber addr;
451 CHECK(ParseIPLiteralToNumber("127.0.0.1", &addr));
[email protected]c05a6d222013-12-16 19:42:03452 return addr;
453}
454
[email protected]730b35d72014-06-05 03:23:22455IPAddressNumber Loopback6() {
456 IPAddressNumber addr;
457 CHECK(ParseIPLiteralToNumber("::1", &addr));
458 return addr;
459}
460
rtennetie0ee6eb2015-05-01 00:55:09461IPAddressNumber Any4() {
462 IPAddressNumber any4;
463 CHECK(net::ParseIPLiteralToNumber("0.0.0.0", &any4));
464 return any4;
465}
466
[email protected]9bb57c72014-03-31 20:36:04467void GenerateBody(string* body, int length) {
468 body->clear();
469 body->reserve(length);
470 for (int i = 0; i < length; ++i) {
471 body->append(1, static_cast<char>(32 + i % (126 - 32)));
472 }
473}
474
rtennetia004d332015-08-28 06:44:57475QuicEncryptedPacket* ConstructEncryptedPacket(QuicConnectionId connection_id,
476 bool version_flag,
jric533399b2016-01-29 07:36:01477 bool multipath_flag,
rtennetia004d332015-08-28 06:44:57478 bool reset_flag,
jric533399b2016-01-29 07:36:01479 QuicPathId path_id,
rtennetia004d332015-08-28 06:44:57480 QuicPacketNumber packet_number,
481 const string& data) {
jric533399b2016-01-29 07:36:01482 return ConstructEncryptedPacket(connection_id, version_flag, multipath_flag,
483 reset_flag, path_id, packet_number, data,
484 PACKET_8BYTE_CONNECTION_ID,
485 PACKET_6BYTE_PACKET_NUMBER);
rtenneti9e0fb502015-03-08 06:07:16486}
487
488QuicEncryptedPacket* ConstructEncryptedPacket(
489 QuicConnectionId connection_id,
490 bool version_flag,
jric533399b2016-01-29 07:36:01491 bool multipath_flag,
rtenneti9e0fb502015-03-08 06:07:16492 bool reset_flag,
jric533399b2016-01-29 07:36:01493 QuicPathId path_id,
rtennetia004d332015-08-28 06:44:57494 QuicPacketNumber packet_number,
rtenneti9e0fb502015-03-08 06:07:16495 const string& data,
496 QuicConnectionIdLength connection_id_length,
rtennetia004d332015-08-28 06:44:57497 QuicPacketNumberLength packet_number_length) {
jric533399b2016-01-29 07:36:01498 return ConstructEncryptedPacket(
499 connection_id, version_flag, multipath_flag, reset_flag, path_id,
500 packet_number, data, connection_id_length, packet_number_length, nullptr);
rchc0815442015-04-18 13:29:46501}
502
503QuicEncryptedPacket* ConstructEncryptedPacket(
504 QuicConnectionId connection_id,
505 bool version_flag,
jric533399b2016-01-29 07:36:01506 bool multipath_flag,
rchc0815442015-04-18 13:29:46507 bool reset_flag,
jric533399b2016-01-29 07:36:01508 QuicPathId path_id,
rtennetia004d332015-08-28 06:44:57509 QuicPacketNumber packet_number,
rchc0815442015-04-18 13:29:46510 const string& data,
511 QuicConnectionIdLength connection_id_length,
rtennetia004d332015-08-28 06:44:57512 QuicPacketNumberLength packet_number_length,
rchc0815442015-04-18 13:29:46513 QuicVersionVector* versions) {
[email protected]ffc34bf2014-03-07 02:42:02514 QuicPacketHeader header;
515 header.public_header.connection_id = connection_id;
rtenneti9e0fb502015-03-08 06:07:16516 header.public_header.connection_id_length = connection_id_length;
[email protected]ffc34bf2014-03-07 02:42:02517 header.public_header.version_flag = version_flag;
jric533399b2016-01-29 07:36:01518 header.public_header.multipath_flag = multipath_flag;
[email protected]ffc34bf2014-03-07 02:42:02519 header.public_header.reset_flag = reset_flag;
rtennetia004d332015-08-28 06:44:57520 header.public_header.packet_number_length = packet_number_length;
jric533399b2016-01-29 07:36:01521 header.path_id = path_id;
rtenneti8dd12b22015-10-21 01:26:38522 header.packet_number = packet_number;
[email protected]ffc34bf2014-03-07 02:42:02523 header.entropy_flag = false;
524 header.entropy_hash = 0;
525 header.fec_flag = false;
526 header.is_in_fec_group = NOT_IN_FEC_GROUP;
527 header.fec_group = 0;
rtennetia4228ea2015-06-04 02:31:44528 QuicStreamFrame stream_frame(1, false, 0, StringPiece(data));
[email protected]ffc34bf2014-03-07 02:42:02529 QuicFrame frame(&stream_frame);
530 QuicFrames frames;
531 frames.push_back(frame);
rchc0815442015-04-18 13:29:46532 QuicFramer framer(versions != nullptr ? *versions : QuicSupportedVersions(),
533 QuicTime::Zero(), Perspective::IS_CLIENT);
534
[email protected]ffc34bf2014-03-07 02:42:02535 scoped_ptr<QuicPacket> packet(
rtennetib6ac61a52015-02-11 20:20:52536 BuildUnsizedDataPacket(&framer, header, frames));
rtennetibe635732014-10-02 22:51:42537 EXPECT_TRUE(packet != nullptr);
rch99b644c2015-11-04 05:25:28538 char* buffer = new char[kMaxPacketSize];
539 size_t encrypted_length = framer.EncryptPayload(
jric533399b2016-01-29 07:36:01540 ENCRYPTION_NONE, path_id, packet_number, *packet, buffer, kMaxPacketSize);
rch99b644c2015-11-04 05:25:28541 EXPECT_NE(0u, encrypted_length);
542 return new QuicEncryptedPacket(buffer, encrypted_length, true);
[email protected]ffc34bf2014-03-07 02:42:02543}
544
rchc0815442015-04-18 13:29:46545QuicEncryptedPacket* ConstructMisFramedEncryptedPacket(
546 QuicConnectionId connection_id,
547 bool version_flag,
jric533399b2016-01-29 07:36:01548 bool multipath_flag,
rchc0815442015-04-18 13:29:46549 bool reset_flag,
jric533399b2016-01-29 07:36:01550 QuicPathId path_id,
rtennetia004d332015-08-28 06:44:57551 QuicPacketNumber packet_number,
rchc0815442015-04-18 13:29:46552 const string& data,
553 QuicConnectionIdLength connection_id_length,
rtennetia004d332015-08-28 06:44:57554 QuicPacketNumberLength packet_number_length,
rchc0815442015-04-18 13:29:46555 QuicVersionVector* versions) {
556 QuicPacketHeader header;
557 header.public_header.connection_id = connection_id;
558 header.public_header.connection_id_length = connection_id_length;
559 header.public_header.version_flag = version_flag;
jric533399b2016-01-29 07:36:01560 header.public_header.multipath_flag = multipath_flag;
rchc0815442015-04-18 13:29:46561 header.public_header.reset_flag = reset_flag;
rtennetia004d332015-08-28 06:44:57562 header.public_header.packet_number_length = packet_number_length;
jric533399b2016-01-29 07:36:01563 header.path_id = path_id;
rtenneti8dd12b22015-10-21 01:26:38564 header.packet_number = packet_number;
rchc0815442015-04-18 13:29:46565 header.entropy_flag = false;
566 header.entropy_hash = 0;
567 header.fec_flag = false;
568 header.is_in_fec_group = NOT_IN_FEC_GROUP;
569 header.fec_group = 0;
rtennetia4228ea2015-06-04 02:31:44570 QuicStreamFrame stream_frame(1, false, 0, StringPiece(data));
rtenneti85816fdf2015-05-25 03:01:10571 QuicFrame frame(&stream_frame);
rchc0815442015-04-18 13:29:46572 QuicFrames frames;
rtenneti85816fdf2015-05-25 03:01:10573 frames.push_back(frame);
574 QuicFramer framer(versions != nullptr ? *versions : QuicSupportedVersions(),
rchc0815442015-04-18 13:29:46575 QuicTime::Zero(), Perspective::IS_CLIENT);
rtenneti85816fdf2015-05-25 03:01:10576
rchc0815442015-04-18 13:29:46577 scoped_ptr<QuicPacket> packet(
578 BuildUnsizedDataPacket(&framer, header, frames));
579 EXPECT_TRUE(packet != nullptr);
rtenneti85816fdf2015-05-25 03:01:10580
581 // Now set the packet's private flags byte to 0xFF, which is an invalid value.
582 reinterpret_cast<unsigned char*>(
583 packet->mutable_data())[GetStartOfEncryptedData(
jric533399b2016-01-29 07:36:01584 connection_id_length, version_flag, multipath_flag,
585 packet_number_length)] = 0xFF;
rtenneti85816fdf2015-05-25 03:01:10586
rch99b644c2015-11-04 05:25:28587 char* buffer = new char[kMaxPacketSize];
588 size_t encrypted_length = framer.EncryptPayload(
jric533399b2016-01-29 07:36:01589 ENCRYPTION_NONE, path_id, packet_number, *packet, buffer, kMaxPacketSize);
rch99b644c2015-11-04 05:25:28590 EXPECT_NE(0u, encrypted_length);
591 return new QuicEncryptedPacket(buffer, encrypted_length, true);
rchc0815442015-04-18 13:29:46592}
593
rjshaded5ced072015-12-18 19:26:02594void CompareCharArraysWithHexError(const string& description,
595 const char* actual,
596 const int actual_len,
597 const char* expected,
598 const int expected_len) {
[email protected]b007e632013-10-28 08:39:25599 EXPECT_EQ(actual_len, expected_len);
[email protected]8b37a092012-10-18 21:53:49600 const int min_len = min(actual_len, expected_len);
601 const int max_len = max(actual_len, expected_len);
[email protected]4356f0f2013-04-07 00:58:17602 scoped_ptr<bool[]> marks(new bool[max_len]);
[email protected]8b37a092012-10-18 21:53:49603 bool identical = (actual_len == expected_len);
604 for (int i = 0; i < min_len; ++i) {
605 if (actual[i] != expected[i]) {
606 marks[i] = true;
607 identical = false;
608 } else {
609 marks[i] = false;
610 }
611 }
612 for (int i = min_len; i < max_len; ++i) {
613 marks[i] = true;
614 }
rjshaded5ced072015-12-18 19:26:02615 if (identical)
616 return;
jric533399b2016-01-29 07:36:01617 ADD_FAILURE() << "Description:\n"
618 << description << "\n\nExpected:\n"
rjshaded5ced072015-12-18 19:26:02619 << HexDumpWithMarks(expected, expected_len, marks.get(),
620 max_len)
621 << "\nActual:\n"
622 << HexDumpWithMarks(actual, actual_len, marks.get(), max_len);
[email protected]8b37a092012-10-18 21:53:49623}
624
[email protected]b12764d2013-12-02 22:28:30625bool DecodeHexString(const base::StringPiece& hex, std::string* bytes) {
626 bytes->clear();
627 if (hex.empty())
628 return true;
Avi Drissman13fc8932015-12-20 04:40:46629 std::vector<uint8_t> v;
[email protected]b12764d2013-12-02 22:28:30630 if (!base::HexStringToBytes(hex.as_string(), &v))
631 return false;
632 if (!v.empty())
633 bytes->assign(reinterpret_cast<const char*>(&v[0]), v.size());
634 return true;
635}
636
[email protected]d3d15bf2013-01-30 02:51:54637static QuicPacket* ConstructPacketFromHandshakeMessage(
[email protected]3aa9ca72014-02-27 19:39:43638 QuicConnectionId connection_id,
[email protected]14e8106c2013-03-14 16:25:33639 const CryptoHandshakeMessage& message,
640 bool should_include_version) {
[email protected]8b37a092012-10-18 21:53:49641 CryptoFramer crypto_framer;
[email protected]dc2cc742012-10-21 13:56:13642 scoped_ptr<QuicData> data(crypto_framer.ConstructHandshakeMessage(message));
rtenneti6f48aa92015-03-16 02:18:48643 QuicFramer quic_framer(QuicSupportedVersions(), QuicTime::Zero(),
644 Perspective::IS_CLIENT);
[email protected]8b37a092012-10-18 21:53:49645
646 QuicPacketHeader header;
[email protected]3aa9ca72014-02-27 19:39:43647 header.public_header.connection_id = connection_id;
[email protected]9db443912013-02-25 05:27:03648 header.public_header.reset_flag = false;
[email protected]14e8106c2013-03-14 16:25:33649 header.public_header.version_flag = should_include_version;
rtenneti8dd12b22015-10-21 01:26:38650 header.packet_number = 1;
[email protected]9db443912013-02-25 05:27:03651 header.entropy_flag = false;
652 header.entropy_hash = 0;
653 header.fec_flag = false;
[email protected]8b37a092012-10-18 21:53:49654 header.fec_group = 0;
655
[email protected]be24ab22012-10-22 03:01:52656 QuicStreamFrame stream_frame(kCryptoStreamId, false, 0,
rtennetia4228ea2015-06-04 02:31:44657 data->AsStringPiece());
[email protected]8b37a092012-10-18 21:53:49658
[email protected]be24ab22012-10-22 03:01:52659 QuicFrame frame(&stream_frame);
660 QuicFrames frames;
661 frames.push_back(frame);
rtennetib6ac61a52015-02-11 20:20:52662 return BuildUnsizedDataPacket(&quic_framer, header, frames);
[email protected]8b37a092012-10-18 21:53:49663}
664
[email protected]3aa9ca72014-02-27 19:39:43665QuicPacket* ConstructHandshakePacket(QuicConnectionId connection_id,
666 QuicTag tag) {
[email protected]d3d15bf2013-01-30 02:51:54667 CryptoHandshakeMessage message;
[email protected]ccc66e8a2013-03-26 08:26:14668 message.set_tag(tag);
[email protected]3aa9ca72014-02-27 19:39:43669 return ConstructPacketFromHandshakeMessage(connection_id, message, false);
[email protected]d3d15bf2013-01-30 02:51:54670}
671
rtennetia004d332015-08-28 06:44:57672size_t GetPacketLengthForOneStream(QuicVersion version,
673 bool include_version,
rchcaec4242016-01-22 20:49:52674 bool include_path_id,
rtennetia004d332015-08-28 06:44:57675 QuicConnectionIdLength connection_id_length,
676 QuicPacketNumberLength packet_number_length,
677 InFecGroup is_in_fec_group,
678 size_t* payload_length) {
[email protected]f62262b2013-07-05 20:57:30679 *payload_length = 1;
680 const size_t stream_length =
[email protected]5dafdb62013-11-14 01:24:26681 NullEncrypter().GetCiphertextSize(*payload_length) +
[email protected]b064310782013-05-30 21:12:17682 QuicPacketCreator::StreamFramePacketOverhead(
rchcaec4242016-01-22 20:49:52683 PACKET_8BYTE_CONNECTION_ID, include_version, include_path_id,
684 packet_number_length, 0u, is_in_fec_group);
rtennetic14c8ab2015-06-18 05:47:40685 const size_t ack_length =
686 NullEncrypter().GetCiphertextSize(
rtennetia004d332015-08-28 06:44:57687 QuicFramer::GetMinAckFrameSize(PACKET_1BYTE_PACKET_NUMBER)) +
rtenneti23186682014-10-30 01:49:33688 GetPacketHeaderSize(connection_id_length, include_version,
rchcaec4242016-01-22 20:49:52689 include_path_id, packet_number_length,
zhongyib8677022015-12-01 05:51:30690 is_in_fec_group);
[email protected]f62262b2013-07-05 20:57:30691 if (stream_length < ack_length) {
692 *payload_length = 1 + ack_length - stream_length;
693 }
694
[email protected]5dafdb62013-11-14 01:24:26695 return NullEncrypter().GetCiphertextSize(*payload_length) +
rtennetia004d332015-08-28 06:44:57696 QuicPacketCreator::StreamFramePacketOverhead(
rchcaec4242016-01-22 20:49:52697 connection_id_length, include_version, include_path_id,
698 packet_number_length, 0u, is_in_fec_group);
[email protected]5351cc4b2013-03-03 07:22:41699}
700
[email protected]a5b98172014-06-18 07:01:59701TestEntropyCalculator::TestEntropyCalculator() {}
[email protected]8e01c062013-10-31 07:35:31702
[email protected]a5b98172014-06-18 07:01:59703TestEntropyCalculator::~TestEntropyCalculator() {}
[email protected]8e01c062013-10-31 07:35:31704
[email protected]48878092013-07-26 14:51:56705QuicPacketEntropyHash TestEntropyCalculator::EntropyHash(
rtennetia004d332015-08-28 06:44:57706 QuicPacketNumber packet_number) const {
[email protected]9db443912013-02-25 05:27:03707 return 1u;
708}
709
[email protected]a5b98172014-06-18 07:01:59710MockEntropyCalculator::MockEntropyCalculator() {}
[email protected]8e01c062013-10-31 07:35:31711
[email protected]a5b98172014-06-18 07:01:59712MockEntropyCalculator::~MockEntropyCalculator() {}
[email protected]8e01c062013-10-31 07:35:31713
[email protected]b064310782013-05-30 21:12:17714QuicConfig DefaultQuicConfig() {
715 QuicConfig config;
[email protected]7d561352014-06-20 09:09:21716 config.SetInitialStreamFlowControlWindowToSend(
717 kInitialStreamFlowControlWindowForTest);
718 config.SetInitialSessionFlowControlWindowToSend(
719 kInitialSessionFlowControlWindowForTest);
[email protected]b064310782013-05-30 21:12:17720 return config;
721}
722
rtennetia2ea9162015-05-15 19:26:44723QuicConfig DefaultQuicConfigStatelessRejects() {
724 QuicConfig config = DefaultQuicConfig();
725 QuicTagVector copt;
726 copt.push_back(kSREJ);
727 config.SetConnectionOptionsToSend(copt);
728 return config;
729}
730
[email protected]4d640792013-12-18 22:21:08731QuicVersionVector SupportedVersions(QuicVersion version) {
732 QuicVersionVector versions;
733 versions.push_back(version);
734 return versions;
735}
736
rtenneti021e8822015-10-18 23:59:57737MockQuicConnectionDebugVisitor::MockQuicConnectionDebugVisitor() {}
rtenneti95293802015-03-27 18:59:23738
rtenneti021e8822015-10-18 23:59:57739MockQuicConnectionDebugVisitor::~MockQuicConnectionDebugVisitor() {}
rtenneti95293802015-03-27 18:59:23740
fayanga31a74b2015-12-28 17:27:14741MockReceivedPacketManager::MockReceivedPacketManager(QuicConnectionStats* stats)
742 : QuicReceivedPacketManager(stats) {}
743
744MockReceivedPacketManager::~MockReceivedPacketManager() {}
745
rtennetid39bd762015-06-12 01:05:52746void CreateClientSessionForTest(QuicServerId server_id,
747 bool supports_stateless_rejects,
748 QuicTime::Delta connection_start_time,
zhongyib8677022015-12-01 05:51:30749 QuicVersionVector supported_versions,
rch99b644c2015-11-04 05:25:28750 MockConnectionHelper* helper,
rtennetid39bd762015-06-12 01:05:52751 QuicCryptoClientConfig* crypto_client_config,
752 PacketSavingConnection** client_connection,
rtennetib865eb82015-06-17 20:21:46753 TestQuicSpdyClientSession** client_session) {
rtennetia2ea9162015-05-15 19:26:44754 CHECK(crypto_client_config);
755 CHECK(client_connection);
756 CHECK(client_session);
rtennetia2ea9162015-05-15 19:26:44757 CHECK(!connection_start_time.IsZero())
758 << "Connections must start at non-zero times, otherwise the "
759 << "strike-register will be unhappy.";
760
761 QuicConfig config = supports_stateless_rejects
762 ? DefaultQuicConfigStatelessRejects()
763 : DefaultQuicConfig();
zhongyib8677022015-12-01 05:51:30764 *client_connection = new PacketSavingConnection(
765 helper, Perspective::IS_CLIENT, supported_versions);
rtennetib865eb82015-06-17 20:21:46766 *client_session = new TestQuicSpdyClientSession(
767 *client_connection, config, server_id, crypto_client_config);
rtennetia2ea9162015-05-15 19:26:44768 (*client_connection)->AdvanceTime(connection_start_time);
769}
770
rtennetid39bd762015-06-12 01:05:52771void CreateServerSessionForTest(QuicServerId server_id,
772 QuicTime::Delta connection_start_time,
zhongyib8677022015-12-01 05:51:30773 QuicVersionVector supported_versions,
rch99b644c2015-11-04 05:25:28774 MockConnectionHelper* helper,
rtennetid39bd762015-06-12 01:05:52775 QuicCryptoServerConfig* server_crypto_config,
776 PacketSavingConnection** server_connection,
rtennetib865eb82015-06-17 20:21:46777 TestQuicSpdyServerSession** server_session) {
rtennetia2ea9162015-05-15 19:26:44778 CHECK(server_crypto_config);
779 CHECK(server_connection);
780 CHECK(server_session);
rtennetia2ea9162015-05-15 19:26:44781 CHECK(!connection_start_time.IsZero())
782 << "Connections must start at non-zero times, otherwise the "
783 << "strike-register will be unhappy.";
784
zhongyib8677022015-12-01 05:51:30785 *server_connection = new PacketSavingConnection(
786 helper, Perspective::IS_SERVER, supported_versions);
rtennetib865eb82015-06-17 20:21:46787 *server_session = new TestQuicSpdyServerSession(
rtennetid39bd762015-06-12 01:05:52788 *server_connection, DefaultQuicConfig(), server_crypto_config);
rtennetia2ea9162015-05-15 19:26:44789
790 // We advance the clock initially because the default time is zero and the
Avi Drissman13fc8932015-12-20 04:40:46791 // strike register worries that we've just overflowed a uint32_t time.
rtennetia2ea9162015-05-15 19:26:44792 (*server_connection)->AdvanceTime(connection_start_time);
793}
794
ckrasic99850b32015-10-16 21:15:58795QuicStreamId QuicClientDataStreamId(int i) {
796 return kClientDataStreamId1 + 2 * i;
797}
798
[email protected]8b37a092012-10-18 21:53:49799} // namespace test
[email protected]8b37a092012-10-18 21:53:49800} // namespace net