Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: net/quic/quic_config_test.cc

Issue 605163004: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0925
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_config.cc ('k') | net/quic/quic_connection.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/quic_config.h" 5 #include "net/quic/quic_config.h"
6 6
7 #include "net/quic/crypto/crypto_handshake_message.h" 7 #include "net/quic/crypto/crypto_handshake_message.h"
8 #include "net/quic/crypto/crypto_protocol.h" 8 #include "net/quic/crypto/crypto_protocol.h"
9 #include "net/quic/quic_flags.h" 9 #include "net/quic/quic_flags.h"
10 #include "net/quic/quic_protocol.h" 10 #include "net/quic/quic_protocol.h"
(...skipping 19 matching lines...) Expand all
30 }; 30 };
31 31
32 TEST_F(QuicConfigTest, ToHandshakeMessage) { 32 TEST_F(QuicConfigTest, ToHandshakeMessage) {
33 config_.SetDefaults(); 33 config_.SetDefaults();
34 config_.SetInitialFlowControlWindowToSend( 34 config_.SetInitialFlowControlWindowToSend(
35 kInitialSessionFlowControlWindowForTest); 35 kInitialSessionFlowControlWindowForTest);
36 config_.SetInitialStreamFlowControlWindowToSend( 36 config_.SetInitialStreamFlowControlWindowToSend(
37 kInitialStreamFlowControlWindowForTest); 37 kInitialStreamFlowControlWindowForTest);
38 config_.SetInitialSessionFlowControlWindowToSend( 38 config_.SetInitialSessionFlowControlWindowToSend(
39 kInitialSessionFlowControlWindowForTest); 39 kInitialSessionFlowControlWindowForTest);
40 config_.set_idle_connection_state_lifetime(QuicTime::Delta::FromSeconds(5), 40 config_.SetIdleConnectionStateLifetime(QuicTime::Delta::FromSeconds(5),
41 QuicTime::Delta::FromSeconds(2)); 41 QuicTime::Delta::FromSeconds(2));
42 config_.set_max_streams_per_connection(4, 2); 42 config_.SetMaxStreamsPerConnection(4, 2);
43 config_.SetSocketReceiveBufferToSend(kDefaultSocketReceiveBuffer); 43 config_.SetSocketReceiveBufferToSend(kDefaultSocketReceiveBuffer);
44 CryptoHandshakeMessage msg; 44 CryptoHandshakeMessage msg;
45 config_.ToHandshakeMessage(&msg); 45 config_.ToHandshakeMessage(&msg);
46 46
47 uint32 value; 47 uint32 value;
48 QuicErrorCode error = msg.GetUint32(kICSL, &value); 48 QuicErrorCode error = msg.GetUint32(kICSL, &value);
49 EXPECT_EQ(QUIC_NO_ERROR, error); 49 EXPECT_EQ(QUIC_NO_ERROR, error);
50 EXPECT_EQ(5u, value); 50 EXPECT_EQ(5u, value);
51 51
52 error = msg.GetUint32(kMSPC, &value); 52 error = msg.GetUint32(kMSPC, &value);
(...skipping 20 matching lines...) Expand all
73 size_t out_len; 73 size_t out_len;
74 error = msg.GetTaglist(kCGST, &out, &out_len); 74 error = msg.GetTaglist(kCGST, &out, &out_len);
75 EXPECT_EQ(1u, out_len); 75 EXPECT_EQ(1u, out_len);
76 EXPECT_EQ(kQBIC, *out); 76 EXPECT_EQ(kQBIC, *out);
77 } 77 }
78 78
79 TEST_F(QuicConfigTest, ProcessClientHello) { 79 TEST_F(QuicConfigTest, ProcessClientHello) {
80 QuicConfig client_config; 80 QuicConfig client_config;
81 QuicTagVector cgst; 81 QuicTagVector cgst;
82 cgst.push_back(kQBIC); 82 cgst.push_back(kQBIC);
83 client_config.set_congestion_feedback(cgst, kQBIC); 83 client_config.SetCongestionFeedback(cgst, kQBIC);
84 client_config.set_idle_connection_state_lifetime( 84 client_config.SetIdleConnectionStateLifetime(
85 QuicTime::Delta::FromSeconds(2 * kMaximumIdleTimeoutSecs), 85 QuicTime::Delta::FromSeconds(2 * kMaximumIdleTimeoutSecs),
86 QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs)); 86 QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs));
87 client_config.set_max_streams_per_connection( 87 client_config.SetMaxStreamsPerConnection(
88 2 * kDefaultMaxStreamsPerConnection, kDefaultMaxStreamsPerConnection); 88 2 * kDefaultMaxStreamsPerConnection, kDefaultMaxStreamsPerConnection);
89 client_config.SetInitialRoundTripTimeUsToSend( 89 client_config.SetInitialRoundTripTimeUsToSend(
90 10 * base::Time::kMicrosecondsPerMillisecond); 90 10 * base::Time::kMicrosecondsPerMillisecond);
91 client_config.SetInitialFlowControlWindowToSend( 91 client_config.SetInitialFlowControlWindowToSend(
92 2 * kInitialSessionFlowControlWindowForTest); 92 2 * kInitialSessionFlowControlWindowForTest);
93 client_config.SetInitialStreamFlowControlWindowToSend( 93 client_config.SetInitialStreamFlowControlWindowToSend(
94 2 * kInitialStreamFlowControlWindowForTest); 94 2 * kInitialStreamFlowControlWindowForTest);
95 client_config.SetInitialSessionFlowControlWindowToSend( 95 client_config.SetInitialSessionFlowControlWindowToSend(
96 2 * kInitialSessionFlowControlWindowForTest); 96 2 * kInitialSessionFlowControlWindowForTest);
97 client_config.SetSocketReceiveBufferToSend(kDefaultSocketReceiveBuffer); 97 client_config.SetSocketReceiveBufferToSend(kDefaultSocketReceiveBuffer);
98 QuicTagVector copt; 98 QuicTagVector copt;
99 copt.push_back(kTBBR); 99 copt.push_back(kTBBR);
100 copt.push_back(kFHDR); 100 copt.push_back(kFHDR);
101 client_config.SetConnectionOptionsToSend(copt); 101 client_config.SetConnectionOptionsToSend(copt);
102 CryptoHandshakeMessage msg; 102 CryptoHandshakeMessage msg;
103 client_config.ToHandshakeMessage(&msg); 103 client_config.ToHandshakeMessage(&msg);
104 string error_details; 104 string error_details;
105 const QuicErrorCode error = 105 const QuicErrorCode error =
106 config_.ProcessPeerHello(msg, CLIENT, &error_details); 106 config_.ProcessPeerHello(msg, CLIENT, &error_details);
107 EXPECT_EQ(QUIC_NO_ERROR, error); 107 EXPECT_EQ(QUIC_NO_ERROR, error);
108 EXPECT_TRUE(config_.negotiated()); 108 EXPECT_TRUE(config_.negotiated());
109 EXPECT_EQ(kQBIC, config_.congestion_feedback()); 109 EXPECT_EQ(kQBIC, config_.CongestionFeedback());
110 EXPECT_EQ(QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs), 110 EXPECT_EQ(QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs),
111 config_.idle_connection_state_lifetime()); 111 config_.IdleConnectionStateLifetime());
112 EXPECT_EQ(kDefaultMaxStreamsPerConnection, 112 EXPECT_EQ(kDefaultMaxStreamsPerConnection,
113 config_.max_streams_per_connection()); 113 config_.MaxStreamsPerConnection());
114 EXPECT_EQ(QuicTime::Delta::FromSeconds(0), config_.keepalive_timeout()); 114 EXPECT_EQ(QuicTime::Delta::FromSeconds(0), config_.KeepaliveTimeout());
115 EXPECT_EQ(10 * base::Time::kMicrosecondsPerMillisecond, 115 EXPECT_EQ(10 * base::Time::kMicrosecondsPerMillisecond,
116 config_.ReceivedInitialRoundTripTimeUs()); 116 config_.ReceivedInitialRoundTripTimeUs());
117 EXPECT_TRUE(config_.HasReceivedConnectionOptions()); 117 EXPECT_TRUE(config_.HasReceivedConnectionOptions());
118 EXPECT_EQ(2u, config_.ReceivedConnectionOptions().size()); 118 EXPECT_EQ(2u, config_.ReceivedConnectionOptions().size());
119 EXPECT_EQ(config_.ReceivedConnectionOptions()[0], kTBBR); 119 EXPECT_EQ(config_.ReceivedConnectionOptions()[0], kTBBR);
120 EXPECT_EQ(config_.ReceivedConnectionOptions()[1], kFHDR); 120 EXPECT_EQ(config_.ReceivedConnectionOptions()[1], kFHDR);
121 EXPECT_EQ(config_.ReceivedInitialFlowControlWindowBytes(), 121 EXPECT_EQ(config_.ReceivedInitialFlowControlWindowBytes(),
122 2 * kInitialSessionFlowControlWindowForTest); 122 2 * kInitialSessionFlowControlWindowForTest);
123 EXPECT_EQ(config_.ReceivedInitialStreamFlowControlWindowBytes(), 123 EXPECT_EQ(config_.ReceivedInitialStreamFlowControlWindowBytes(),
124 2 * kInitialStreamFlowControlWindowForTest); 124 2 * kInitialStreamFlowControlWindowForTest);
125 EXPECT_EQ(config_.ReceivedInitialSessionFlowControlWindowBytes(), 125 EXPECT_EQ(config_.ReceivedInitialSessionFlowControlWindowBytes(),
126 2 * kInitialSessionFlowControlWindowForTest); 126 2 * kInitialSessionFlowControlWindowForTest);
127 EXPECT_EQ(config_.ReceivedSocketReceiveBuffer(), 127 EXPECT_EQ(config_.ReceivedSocketReceiveBuffer(),
128 kDefaultSocketReceiveBuffer); 128 kDefaultSocketReceiveBuffer);
129 } 129 }
130 130
131 TEST_F(QuicConfigTest, ProcessServerHello) { 131 TEST_F(QuicConfigTest, ProcessServerHello) {
132 QuicConfig server_config; 132 QuicConfig server_config;
133 QuicTagVector cgst; 133 QuicTagVector cgst;
134 cgst.push_back(kQBIC); 134 cgst.push_back(kQBIC);
135 server_config.set_congestion_feedback(cgst, kQBIC); 135 server_config.SetCongestionFeedback(cgst, kQBIC);
136 server_config.set_idle_connection_state_lifetime( 136 server_config.SetIdleConnectionStateLifetime(
137 QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs / 2), 137 QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs / 2),
138 QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs / 2)); 138 QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs / 2));
139 server_config.set_max_streams_per_connection( 139 server_config.SetMaxStreamsPerConnection(
140 kDefaultMaxStreamsPerConnection / 2, 140 kDefaultMaxStreamsPerConnection / 2,
141 kDefaultMaxStreamsPerConnection / 2); 141 kDefaultMaxStreamsPerConnection / 2);
142 server_config.SetInitialCongestionWindowToSend(kDefaultInitialWindow / 2); 142 server_config.SetInitialCongestionWindowToSend(kDefaultInitialWindow / 2);
143 server_config.SetInitialRoundTripTimeUsToSend( 143 server_config.SetInitialRoundTripTimeUsToSend(
144 10 * base::Time::kMicrosecondsPerMillisecond); 144 10 * base::Time::kMicrosecondsPerMillisecond);
145 server_config.SetInitialFlowControlWindowToSend( 145 server_config.SetInitialFlowControlWindowToSend(
146 2 * kInitialSessionFlowControlWindowForTest); 146 2 * kInitialSessionFlowControlWindowForTest);
147 server_config.SetInitialStreamFlowControlWindowToSend( 147 server_config.SetInitialStreamFlowControlWindowToSend(
148 2 * kInitialStreamFlowControlWindowForTest); 148 2 * kInitialStreamFlowControlWindowForTest);
149 server_config.SetInitialSessionFlowControlWindowToSend( 149 server_config.SetInitialSessionFlowControlWindowToSend(
150 2 * kInitialSessionFlowControlWindowForTest); 150 2 * kInitialSessionFlowControlWindowForTest);
151 server_config.SetSocketReceiveBufferToSend(kDefaultSocketReceiveBuffer); 151 server_config.SetSocketReceiveBufferToSend(kDefaultSocketReceiveBuffer);
152 CryptoHandshakeMessage msg; 152 CryptoHandshakeMessage msg;
153 server_config.ToHandshakeMessage(&msg); 153 server_config.ToHandshakeMessage(&msg);
154 string error_details; 154 string error_details;
155 const QuicErrorCode error = 155 const QuicErrorCode error =
156 config_.ProcessPeerHello(msg, SERVER, &error_details); 156 config_.ProcessPeerHello(msg, SERVER, &error_details);
157 EXPECT_EQ(QUIC_NO_ERROR, error); 157 EXPECT_EQ(QUIC_NO_ERROR, error);
158 EXPECT_TRUE(config_.negotiated()); 158 EXPECT_TRUE(config_.negotiated());
159 EXPECT_EQ(kQBIC, config_.congestion_feedback()); 159 EXPECT_EQ(kQBIC, config_.CongestionFeedback());
160 EXPECT_EQ(QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs / 2), 160 EXPECT_EQ(QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs / 2),
161 config_.idle_connection_state_lifetime()); 161 config_.IdleConnectionStateLifetime());
162 EXPECT_EQ(kDefaultMaxStreamsPerConnection / 2, 162 EXPECT_EQ(kDefaultMaxStreamsPerConnection / 2,
163 config_.max_streams_per_connection()); 163 config_.MaxStreamsPerConnection());
164 EXPECT_EQ(kDefaultInitialWindow / 2, 164 EXPECT_EQ(kDefaultInitialWindow / 2,
165 config_.ReceivedInitialCongestionWindow()); 165 config_.ReceivedInitialCongestionWindow());
166 EXPECT_EQ(QuicTime::Delta::FromSeconds(0), config_.keepalive_timeout()); 166 EXPECT_EQ(QuicTime::Delta::FromSeconds(0), config_.KeepaliveTimeout());
167 EXPECT_EQ(10 * base::Time::kMicrosecondsPerMillisecond, 167 EXPECT_EQ(10 * base::Time::kMicrosecondsPerMillisecond,
168 config_.ReceivedInitialRoundTripTimeUs()); 168 config_.ReceivedInitialRoundTripTimeUs());
169 EXPECT_EQ(config_.ReceivedInitialFlowControlWindowBytes(), 169 EXPECT_EQ(config_.ReceivedInitialFlowControlWindowBytes(),
170 2 * kInitialSessionFlowControlWindowForTest); 170 2 * kInitialSessionFlowControlWindowForTest);
171 EXPECT_EQ(config_.ReceivedInitialStreamFlowControlWindowBytes(), 171 EXPECT_EQ(config_.ReceivedInitialStreamFlowControlWindowBytes(),
172 2 * kInitialStreamFlowControlWindowForTest); 172 2 * kInitialStreamFlowControlWindowForTest);
173 EXPECT_EQ(config_.ReceivedInitialSessionFlowControlWindowBytes(), 173 EXPECT_EQ(config_.ReceivedInitialSessionFlowControlWindowBytes(),
174 2 * kInitialSessionFlowControlWindowForTest); 174 2 * kInitialSessionFlowControlWindowForTest);
175 EXPECT_EQ(config_.ReceivedSocketReceiveBuffer(), 175 EXPECT_EQ(config_.ReceivedSocketReceiveBuffer(),
176 kDefaultSocketReceiveBuffer); 176 kDefaultSocketReceiveBuffer);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 msg.SetValue(kMSPC, 3); 229 msg.SetValue(kMSPC, 3);
230 // Missing CGST. KATO is optional. 230 // Missing CGST. KATO is optional.
231 string error_details; 231 string error_details;
232 const QuicErrorCode error = 232 const QuicErrorCode error =
233 config_.ProcessPeerHello(msg, SERVER, &error_details); 233 config_.ProcessPeerHello(msg, SERVER, &error_details);
234 EXPECT_EQ(QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND, error); 234 EXPECT_EQ(QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND, error);
235 } 235 }
236 236
237 TEST_F(QuicConfigTest, OutOfBoundSHLO) { 237 TEST_F(QuicConfigTest, OutOfBoundSHLO) {
238 QuicConfig server_config; 238 QuicConfig server_config;
239 server_config.set_idle_connection_state_lifetime( 239 server_config.SetIdleConnectionStateLifetime(
240 QuicTime::Delta::FromSeconds(2 * kMaximumIdleTimeoutSecs), 240 QuicTime::Delta::FromSeconds(2 * kMaximumIdleTimeoutSecs),
241 QuicTime::Delta::FromSeconds(2 * kMaximumIdleTimeoutSecs)); 241 QuicTime::Delta::FromSeconds(2 * kMaximumIdleTimeoutSecs));
242 242
243 CryptoHandshakeMessage msg; 243 CryptoHandshakeMessage msg;
244 server_config.ToHandshakeMessage(&msg); 244 server_config.ToHandshakeMessage(&msg);
245 string error_details; 245 string error_details;
246 const QuicErrorCode error = 246 const QuicErrorCode error =
247 config_.ProcessPeerHello(msg, SERVER, &error_details); 247 config_.ProcessPeerHello(msg, SERVER, &error_details);
248 EXPECT_EQ(QUIC_INVALID_NEGOTIATED_VALUE, error); 248 EXPECT_EQ(QUIC_INVALID_NEGOTIATED_VALUE, error);
249 } 249 }
250 250
251 TEST_F(QuicConfigTest, MultipleNegotiatedValuesInVectorTag) { 251 TEST_F(QuicConfigTest, MultipleNegotiatedValuesInVectorTag) {
252 QuicConfig server_config; 252 QuicConfig server_config;
253 QuicTagVector cgst; 253 QuicTagVector cgst;
254 cgst.push_back(kQBIC); 254 cgst.push_back(kQBIC);
255 cgst.push_back(kTBBR); 255 cgst.push_back(kTBBR);
256 server_config.set_congestion_feedback(cgst, kQBIC); 256 server_config.SetCongestionFeedback(cgst, kQBIC);
257 257
258 CryptoHandshakeMessage msg; 258 CryptoHandshakeMessage msg;
259 server_config.ToHandshakeMessage(&msg); 259 server_config.ToHandshakeMessage(&msg);
260 string error_details; 260 string error_details;
261 const QuicErrorCode error = 261 const QuicErrorCode error =
262 config_.ProcessPeerHello(msg, SERVER, &error_details); 262 config_.ProcessPeerHello(msg, SERVER, &error_details);
263 EXPECT_EQ(QUIC_INVALID_NEGOTIATED_VALUE, error); 263 EXPECT_EQ(QUIC_INVALID_NEGOTIATED_VALUE, error);
264 } 264 }
265 265
266 TEST_F(QuicConfigTest, NoOverLapInCGST) { 266 TEST_F(QuicConfigTest, NoOverLapInCGST) {
267 QuicConfig server_config; 267 QuicConfig server_config;
268 server_config.SetDefaults(); 268 server_config.SetDefaults();
269 QuicTagVector cgst; 269 QuicTagVector cgst;
270 cgst.push_back(kTBBR); 270 cgst.push_back(kTBBR);
271 server_config.set_congestion_feedback(cgst, kTBBR); 271 server_config.SetCongestionFeedback(cgst, kTBBR);
272 272
273 CryptoHandshakeMessage msg; 273 CryptoHandshakeMessage msg;
274 string error_details; 274 string error_details;
275 server_config.ToHandshakeMessage(&msg); 275 server_config.ToHandshakeMessage(&msg);
276 const QuicErrorCode error = 276 const QuicErrorCode error =
277 config_.ProcessPeerHello(msg, CLIENT, &error_details); 277 config_.ProcessPeerHello(msg, CLIENT, &error_details);
278 DVLOG(1) << QuicUtils::ErrorToString(error); 278 DVLOG(1) << QuicUtils::ErrorToString(error);
279 EXPECT_EQ(QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP, error); 279 EXPECT_EQ(QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP, error);
280 } 280 }
281 281
282 TEST_F(QuicConfigTest, InvalidFlowControlWindow) { 282 TEST_F(QuicConfigTest, InvalidFlowControlWindow) {
283 // QuicConfig should not accept an invalid flow control window to send to the 283 // QuicConfig should not accept an invalid flow control window to send to the
284 // peer: the receive window must be at least the default of 16 Kb. 284 // peer: the receive window must be at least the default of 16 Kb.
285 QuicConfig config; 285 QuicConfig config;
286 const uint64 kInvalidWindow = kDefaultFlowControlSendWindow - 1; 286 const uint64 kInvalidWindow = kDefaultFlowControlSendWindow - 1;
287 EXPECT_DFATAL(config.SetInitialFlowControlWindowToSend(kInvalidWindow), 287 EXPECT_DFATAL(config.SetInitialFlowControlWindowToSend(kInvalidWindow),
288 "Initial flow control receive window"); 288 "Initial flow control receive window");
289 289
290 EXPECT_EQ(kDefaultFlowControlSendWindow, 290 EXPECT_EQ(kDefaultFlowControlSendWindow,
291 config.GetInitialFlowControlWindowToSend()); 291 config.GetInitialFlowControlWindowToSend());
292 } 292 }
293 293
294 } // namespace 294 } // namespace
295 } // namespace test 295 } // namespace test
296 } // namespace net 296 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_config.cc ('k') | net/quic/quic_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698