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

Unified Diff: net/quic/core/quic_framer_test.cc

Issue 2809723002: Let QUIC_VERSION_38 support IETF PADDING frame (1 byte frame with type 0x00) and respect NSTP conne… (Closed)
Patch Set: Remove old FLAGS_quic_enable_version_38 Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/core/quic_framer.cc ('k') | net/quic/core/quic_version_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/core/quic_framer_test.cc
diff --git a/net/quic/core/quic_framer_test.cc b/net/quic/core/quic_framer_test.cc
index cf757fa6d2af4ef41ec0a8ce7ec2b852bbc03cbe..62769b6b7e6fe4138238bc965f06420b21c8be68 100644
--- a/net/quic/core/quic_framer_test.cc
+++ b/net/quic/core/quic_framer_test.cc
@@ -1075,6 +1075,8 @@ TEST_P(QuicFramerTest, PacketWithDiversificationNonce) {
for (char i = 0; i < 32; ++i) {
EXPECT_EQ(i, (*visitor_.public_header_->nonce)[static_cast<size_t>(i)]);
}
+ EXPECT_EQ(1u, visitor_.padding_frames_.size());
+ EXPECT_EQ(5, visitor_.padding_frames_[0]->num_padding_bytes);
};
TEST_P(QuicFramerTest, LargePublicFlagWithMismatchedVersions) {
@@ -1127,6 +1129,8 @@ TEST_P(QuicFramerTest, LargePublicFlagWithMismatchedVersions) {
ASSERT_TRUE(visitor_.header_.get());
EXPECT_EQ(0, visitor_.frame_count_);
EXPECT_EQ(1, visitor_.version_mismatch_);
+ EXPECT_EQ(1u, visitor_.padding_frames_.size());
+ EXPECT_EQ(5, visitor_.padding_frames_[0]->num_padding_bytes);
};
TEST_P(QuicFramerTest, PaddingFrame) {
@@ -1187,6 +1191,10 @@ TEST_P(QuicFramerTest, PaddingFrame) {
};
// clang-format on
+ if (framer_.version() > QUIC_VERSION_37) {
+ return;
+ }
+
QuicEncryptedPacket encrypted(
AsChars(FLAGS_quic_restart_flag_quic_big_endian_connection_id
? packet_cid_be
@@ -1203,6 +1211,8 @@ TEST_P(QuicFramerTest, PaddingFrame) {
ASSERT_EQ(0u, visitor_.stream_frames_.size());
EXPECT_EQ(0u, visitor_.ack_frames_.size());
+ EXPECT_EQ(1u, visitor_.padding_frames_.size());
+ EXPECT_EQ(28, visitor_.padding_frames_[0]->num_padding_bytes);
// A packet with no frames is not acceptable.
CheckProcessingFails(
FLAGS_quic_restart_flag_quic_big_endian_connection_id ? packet_cid_be
@@ -1213,6 +1223,95 @@ TEST_P(QuicFramerTest, PaddingFrame) {
"Packet has no frames.", QUIC_MISSING_PAYLOAD);
}
+TEST_P(QuicFramerTest, NewPaddingFrame) {
+ // clang-format off
+ unsigned char packet[] = {
+ // public flags (8 byte connection_id)
+ 0x38,
+ // connection_id
+ 0x10, 0x32, 0x54, 0x76,
+ 0x98, 0xBA, 0xDC, 0xFE,
+ // packet number
+ 0xBC, 0x9A, 0x78, 0x56,
+ 0x34, 0x12,
+
+ // paddings
+ 0x00, 0x00,
+ // frame type (stream frame with fin)
+ 0xFF,
+ // stream id
+ 0x04, 0x03, 0x02, 0x01,
+ // offset
+ 0x54, 0x76, 0x10, 0x32,
+ 0xDC, 0xFE, 0x98, 0xBA,
+ // data length
+ 0x0c, 0x00,
+ // data
+ 'h', 'e', 'l', 'l',
+ 'o', ' ', 'w', 'o',
+ 'r', 'l', 'd', '!',
+ // paddings
+ 0x00, 0x00,
+ };
+
+ unsigned char packet_cid_be[] = {
+ // public flags (8 byte connection_id)
+ 0x38,
+ // connection_id
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10,
+ // packet number
+ 0xBC, 0x9A, 0x78, 0x56,
+ 0x34, 0x12,
+
+ // paddings
+ 0x00, 0x00,
+ // frame type (stream frame with fin)
+ 0xFF,
+ // stream id
+ 0x04, 0x03, 0x02, 0x01,
+ // offset
+ 0x54, 0x76, 0x10, 0x32,
+ 0xDC, 0xFE, 0x98, 0xBA,
+ // data length
+ 0x0c, 0x00,
+ // data
+ 'h', 'e', 'l', 'l',
+ 'o', ' ', 'w', 'o',
+ 'r', 'l', 'd', '!',
+ // paddings
+ 0x00, 0x00,
+ };
+ // clang-format on
+
+ if (framer_.version() <= QUIC_VERSION_37) {
+ return;
+ }
+
+ QuicEncryptedPacket encrypted(
+ AsChars(FLAGS_quic_restart_flag_quic_big_endian_connection_id
+ ? packet_cid_be
+ : packet),
+ FLAGS_quic_restart_flag_quic_big_endian_connection_id
+ ? arraysize(packet_cid_be)
+ : arraysize(packet),
+ false);
+ EXPECT_TRUE(framer_.ProcessPacket(encrypted));
+ EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
+ ASSERT_TRUE(visitor_.header_.get());
+ EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion,
+ !kIncludeDiversificationNonce));
+
+ ASSERT_EQ(1u, visitor_.stream_frames_.size());
+ EXPECT_EQ(0u, visitor_.ack_frames_.size());
+ EXPECT_EQ(2u, visitor_.padding_frames_.size());
+ EXPECT_EQ(2, visitor_.padding_frames_[0]->num_padding_bytes);
+ EXPECT_EQ(2, visitor_.padding_frames_[1]->num_padding_bytes);
+ EXPECT_EQ(kStreamId, visitor_.stream_frames_[0]->stream_id);
+ EXPECT_TRUE(visitor_.stream_frames_[0]->fin);
+ EXPECT_EQ(kStreamOffset, visitor_.stream_frames_[0]->offset);
+ CheckStreamFrameData("hello world!", visitor_.stream_frames_[0].get());
+}
+
TEST_P(QuicFramerTest, StreamFrame) {
// clang-format off
unsigned char packet[] = {
@@ -3250,6 +3349,94 @@ TEST_P(QuicFramerTest, BuildPaddingFramePacket) {
: arraysize(packet));
}
+TEST_P(QuicFramerTest, BuildStreamFramePacketWithNewPaddingFrame) {
+ if (framer_.version() <= QUIC_VERSION_37) {
+ return;
+ }
+ QuicPacketHeader header;
+ header.public_header.connection_id = kConnectionId;
+ header.public_header.reset_flag = false;
+ header.public_header.version_flag = false;
+ header.packet_number = kPacketNumber;
+
+ QuicStreamFrame stream_frame(kStreamId, true, kStreamOffset,
+ QuicStringPiece("hello world!"));
+ QuicPaddingFrame padding_frame(2);
+ QuicFrames frames = {QuicFrame(padding_frame), QuicFrame(&stream_frame),
+ QuicFrame(padding_frame)};
+
+ // clang-format off
+ unsigned char packet[] = {
+ // public flags (8 byte connection_id)
+ 0x38,
+ // connection_id
+ 0x10, 0x32, 0x54, 0x76,
+ 0x98, 0xBA, 0xDC, 0xFE,
+ // packet number
+ 0xBC, 0x9A, 0x78, 0x56,
+ 0x34, 0x12,
+
+ // paddings
+ 0x00, 0x00,
+ // frame type (stream frame with fin)
+ 0xFF,
+ // stream id
+ 0x04, 0x03, 0x02, 0x01,
+ // offset
+ 0x54, 0x76, 0x10, 0x32,
+ 0xDC, 0xFE, 0x98, 0xBA,
+ // data length
+ 0x0c, 0x00,
+ // data
+ 'h', 'e', 'l', 'l',
+ 'o', ' ', 'w', 'o',
+ 'r', 'l', 'd', '!',
+ // paddings
+ 0x00, 0x00,
+ };
+
+ unsigned char packet_cid_be[] = {
+ // public flags (8 byte connection_id)
+ 0x38,
+ // connection_id
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10,
+ // packet number
+ 0xBC, 0x9A, 0x78, 0x56,
+ 0x34, 0x12,
+
+ // paddings
+ 0x00, 0x00,
+ // frame type (stream frame with fin)
+ 0xFF,
+ // stream id
+ 0x04, 0x03, 0x02, 0x01,
+ // offset
+ 0x54, 0x76, 0x10, 0x32,
+ 0xDC, 0xFE, 0x98, 0xBA,
+ // data length
+ 0x0c, 0x00,
+ // data
+ 'h', 'e', 'l', 'l',
+ 'o', ' ', 'w', 'o',
+ 'r', 'l', 'd', '!',
+ // paddings
+ 0x00, 0x00,
+ };
+ // clang-format on
+
+ std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames));
+ ASSERT_TRUE(data != nullptr);
+
+ test::CompareCharArraysWithHexError(
+ "constructed packet", data->data(), data->length(),
+ AsChars(FLAGS_quic_restart_flag_quic_big_endian_connection_id
+ ? packet_cid_be
+ : packet),
+ FLAGS_quic_restart_flag_quic_big_endian_connection_id
+ ? arraysize(packet_cid_be)
+ : arraysize(packet));
+}
+
TEST_P(QuicFramerTest, Build4ByteSequenceNumberPaddingFramePacket) {
QuicPacketHeader header;
header.public_header.connection_id = kConnectionId;
« no previous file with comments | « net/quic/core/quic_framer.cc ('k') | net/quic/core/quic_version_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698