gfe-relnote: In QUIC v48, support partial write of CRYPTO frames. Protected by existing gfe2_reloadable_flag_quic_enable_version_48.
PiperOrigin-RevId: 264373472
Change-Id: I285900280e459bbd70e519ec1e78dc2fa518e4c4
diff --git a/quic/core/quic_crypto_stream_test.cc b/quic/core/quic_crypto_stream_test.cc
index 4117786..9d3bda5 100644
--- a/quic/core/quic_crypto_stream_test.cc
+++ b/quic/core/quic_crypto_stream_test.cc
@@ -23,6 +23,7 @@
using testing::InSequence;
using testing::Invoke;
using testing::InvokeWithoutArgs;
+using testing::Return;
namespace quic {
namespace test {
@@ -532,6 +533,43 @@
}
}
+TEST_F(QuicCryptoStreamTest, WriteBufferedCryptoFrames) {
+ if (!QuicVersionUsesCryptoFrames(connection_->transport_version())) {
+ return;
+ }
+ EXPECT_FALSE(stream_->HasBufferedCryptoFrames());
+ InSequence s;
+ // Send [0, 1350) in ENCRYPTION_INITIAL.
+ EXPECT_EQ(ENCRYPTION_INITIAL, connection_->encryption_level());
+ std::string data(1350, 'a');
+ // Only consumed 1000 bytes.
+ EXPECT_CALL(*connection_, SendCryptoData(ENCRYPTION_INITIAL, 1350, 0))
+ .WillOnce(Return(1000));
+ stream_->WriteCryptoData(ENCRYPTION_INITIAL, data);
+ EXPECT_TRUE(stream_->HasBufferedCryptoFrames());
+
+ // Send [1350, 2700) in ENCRYPTION_ZERO_RTT and verify no write is attempted
+ // because there is buffered data.
+ EXPECT_CALL(*connection_, SendCryptoData(_, _, _)).Times(0);
+ connection_->SetDefaultEncryptionLevel(ENCRYPTION_ZERO_RTT);
+ stream_->WriteCryptoData(ENCRYPTION_ZERO_RTT, data);
+ EXPECT_EQ(ENCRYPTION_ZERO_RTT, connection_->encryption_level());
+
+ EXPECT_CALL(*connection_, SendCryptoData(ENCRYPTION_INITIAL, 350, 1000))
+ .WillOnce(Return(350));
+ // Partial write of ENCRYPTION_ZERO_RTT data.
+ EXPECT_CALL(*connection_, SendCryptoData(ENCRYPTION_ZERO_RTT, 1350, 0))
+ .WillOnce(Return(1000));
+ stream_->WriteBufferedCryptoFrames();
+ EXPECT_TRUE(stream_->HasBufferedCryptoFrames());
+ EXPECT_EQ(ENCRYPTION_ZERO_RTT, connection_->encryption_level());
+
+ EXPECT_CALL(*connection_, SendCryptoData(ENCRYPTION_ZERO_RTT, 350, 1000))
+ .WillOnce(Return(350));
+ stream_->WriteBufferedCryptoFrames();
+ EXPECT_FALSE(stream_->HasBufferedCryptoFrames());
+}
+
} // namespace
} // namespace test
} // namespace quic