From d0c61cd8c703f4ab8bf9fb18eb270d5a28ec9177 Mon Sep 17 00:00:00 2001 From: Viktor Chynarov Date: Mon, 30 Sep 2019 17:38:20 -0700 Subject: [PATCH] Add unit test for sending RetireConnectionIdFrame Reviewed By: sharma95 Differential Revision: D15267820 fbshipit-source-id: b885ca6b5dfa7262338168a796caedf391189d85 --- quic/api/test/QuicTransportTest.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/quic/api/test/QuicTransportTest.cpp b/quic/api/test/QuicTransportTest.cpp index ae5ef6c3a..308811f01 100644 --- a/quic/api/test/QuicTransportTest.cpp +++ b/quic/api/test/QuicTransportTest.cpp @@ -1483,6 +1483,33 @@ TEST_F(QuicTransportTest, ResendNewConnectionIdOnLoss) { [&](auto&) { return false; })); } +TEST_F(QuicTransportTest, SendRetireConnectionIdFrame) { + EXPECT_CALL(*socket_, write(_, _)).WillOnce(Invoke(bufLength)); + auto& conn = transport_->getConnectionState(); + RetireConnectionIdFrame retireConnId(1); + sendSimpleFrame(conn, retireConnId); + transport_->updateWriteLooper(true); + loopForWrites(); + + EXPECT_TRUE(conn.pendingEvents.frames.empty()); + EXPECT_EQ(1, transport_->getConnectionState().outstandingPackets.size()); + auto packet = + getLastOutstandingPacket( + transport_->getConnectionState(), PacketNumberSpace::AppData) + ->packet; + bool foundRetireConnectionId = false; + for (auto& simpleFrame : all_frames(packet.frames)) { + folly::variant_match( + simpleFrame, + [&](const RetireConnectionIdFrame& frame) { + EXPECT_EQ(frame, retireConnId); + foundRetireConnectionId = true; + }, + [&](auto&) {}); + } + EXPECT_TRUE(foundRetireConnectionId); +} + TEST_F(QuicTransportTest, NonWritableStreamAPI) { auto streamId = transport_->createBidirectionalStream().value(); auto buf = buildRandomInputData(20);