| Index: net/quic/quic_connection_test.cc
|
| diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc
|
| index e79ed5a3199aa03b54893974cd4cbb6c8651095b..fe35556638dd5a50c0891ff522ecc274e79df943 100644
|
| --- a/net/quic/quic_connection_test.cc
|
| +++ b/net/quic/quic_connection_test.cc
|
| @@ -2426,7 +2426,7 @@ TEST_P(QuicConnectionTest, DoNotSendQueuedPacketForResetStream) {
|
| connection_.SendStreamDataWithString(stream_id, "foo", 0, !kFin, nullptr);
|
|
|
| // Now that there is a queued packet, reset the stream.
|
| - connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14);
|
| + connection_.SendRstStream(stream_id, QUIC_ERROR_PROCESSING_STREAM, 14);
|
|
|
| // Unblock the connection and verify that only the RST_STREAM is sent.
|
| EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
|
| @@ -2436,6 +2436,30 @@ TEST_P(QuicConnectionTest, DoNotSendQueuedPacketForResetStream) {
|
| EXPECT_EQ(1u, writer_->rst_stream_frames().size());
|
| }
|
|
|
| +TEST_P(QuicConnectionTest, SendQueuedPacketForQuicRstStreamNoError) {
|
| + // Block the connection to queue the packet.
|
| + BlockOnNextWrite();
|
| +
|
| + QuicStreamId stream_id = 2;
|
| + connection_.SendStreamDataWithString(stream_id, "foo", 0, !kFin, nullptr);
|
| +
|
| + // Now that there is a queued packet, reset the stream.
|
| + connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14);
|
| +
|
| + // Unblock the connection and verify that the RST_STREAM is sent and the data
|
| + // packet is sent on QUIC_VERSION_29 or later versions.
|
| + if (version() > QUIC_VERSION_28) {
|
| + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
|
| + .Times(AtLeast(2));
|
| + } else {
|
| + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
|
| + }
|
| + writer_->SetWritable();
|
| + connection_.OnCanWrite();
|
| + EXPECT_EQ(1u, writer_->frame_count());
|
| + EXPECT_EQ(1u, writer_->rst_stream_frames().size());
|
| +}
|
| +
|
| TEST_P(QuicConnectionTest, DoNotRetransmitForResetStreamOnNack) {
|
| QuicStreamId stream_id = 2;
|
| QuicPacketNumber last_packet;
|
| @@ -2444,7 +2468,7 @@ TEST_P(QuicConnectionTest, DoNotRetransmitForResetStreamOnNack) {
|
| SendStreamDataToPeer(stream_id, "fooos", 7, !kFin, &last_packet);
|
|
|
| EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
|
| - connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14);
|
| + connection_.SendRstStream(stream_id, QUIC_ERROR_PROCESSING_STREAM, 14);
|
|
|
| // Lose a packet and ensure it does not trigger retransmission.
|
| QuicAckFrame nack_two = InitAckFrame(last_packet);
|
| @@ -2459,14 +2483,43 @@ TEST_P(QuicConnectionTest, DoNotRetransmitForResetStreamOnNack) {
|
| ProcessAckPacket(&nack_two);
|
| }
|
|
|
| -TEST_P(QuicConnectionTest, DoNotRetransmitForResetStreamOnRTO) {
|
| +TEST_P(QuicConnectionTest, RetransmitForQuicRstStreamNoErrorOnNack) {
|
| QuicStreamId stream_id = 2;
|
| QuicPacketNumber last_packet;
|
| SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet);
|
| + SendStreamDataToPeer(stream_id, "foos", 3, !kFin, &last_packet);
|
| + SendStreamDataToPeer(stream_id, "fooos", 7, !kFin, &last_packet);
|
|
|
| EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
|
| connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14);
|
|
|
| + // Lose a packet, ensure it triggers retransmission on QUIC_VERSION_29
|
| + // or later versions.
|
| + QuicAckFrame nack_two = InitAckFrame(last_packet);
|
| + NackPacket(last_packet - 1, &nack_two);
|
| + PacketNumberSet lost_packets;
|
| + lost_packets.insert(last_packet - 1);
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| + EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
|
| + .WillOnce(Return(lost_packets));
|
| + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
|
| + if (version() > QUIC_VERSION_28) {
|
| + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
|
| + .Times(AtLeast(1));
|
| + } else {
|
| + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0);
|
| + }
|
| + ProcessAckPacket(&nack_two);
|
| +}
|
| +
|
| +TEST_P(QuicConnectionTest, DoNotRetransmitForResetStreamOnRTO) {
|
| + QuicStreamId stream_id = 2;
|
| + QuicPacketNumber last_packet;
|
| + SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet);
|
| +
|
| + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
|
| + connection_.SendRstStream(stream_id, QUIC_ERROR_PROCESSING_STREAM, 14);
|
| +
|
| // Fire the RTO and verify that the RST_STREAM is resent, not stream data.
|
| EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
|
| clock_.AdvanceTime(DefaultRetransmissionTime());
|
| @@ -2476,6 +2529,29 @@ TEST_P(QuicConnectionTest, DoNotRetransmitForResetStreamOnRTO) {
|
| EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id);
|
| }
|
|
|
| +TEST_P(QuicConnectionTest, RetransmitForQuicRstStreamNoErrorOnRTO) {
|
| + QuicStreamId stream_id = 2;
|
| + QuicPacketNumber last_packet;
|
| + SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet);
|
| +
|
| + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
|
| + connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14);
|
| +
|
| + // Fire the RTO and verify that the RST_STREAM is resent, the stream data
|
| + // is only sent on QUIC_VERSION_29 or later versions.
|
| + if (version() > QUIC_VERSION_28) {
|
| + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
|
| + .Times(AtLeast(2));
|
| + } else {
|
| + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
|
| + }
|
| + clock_.AdvanceTime(DefaultRetransmissionTime());
|
| + connection_.GetRetransmissionAlarm()->Fire();
|
| + EXPECT_EQ(1u, writer_->frame_count());
|
| + EXPECT_EQ(1u, writer_->rst_stream_frames().size());
|
| + EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id);
|
| +}
|
| +
|
| TEST_P(QuicConnectionTest, DoNotSendPendingRetransmissionForResetStream) {
|
| QuicStreamId stream_id = 2;
|
| QuicPacketNumber last_packet;
|
| @@ -2496,7 +2572,7 @@ TEST_P(QuicConnectionTest, DoNotSendPendingRetransmissionForResetStream) {
|
| EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0);
|
| ProcessAckPacket(&ack);
|
|
|
| - connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14);
|
| + connection_.SendRstStream(stream_id, QUIC_ERROR_PROCESSING_STREAM, 14);
|
|
|
| // Unblock the connection and verify that the RST_STREAM is sent but not the
|
| // second data packet nor a retransmit.
|
| @@ -2508,6 +2584,48 @@ TEST_P(QuicConnectionTest, DoNotSendPendingRetransmissionForResetStream) {
|
| EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id);
|
| }
|
|
|
| +TEST_P(QuicConnectionTest, SendPendingRetransmissionForQuicRstStreamNoError) {
|
| + QuicStreamId stream_id = 2;
|
| + QuicPacketNumber last_packet;
|
| + SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet);
|
| + SendStreamDataToPeer(stream_id, "foos", 3, !kFin, &last_packet);
|
| + BlockOnNextWrite();
|
| + connection_.SendStreamDataWithString(stream_id, "fooos", 7, !kFin, nullptr);
|
| +
|
| + // Lose a packet which will trigger a pending retransmission.
|
| + QuicAckFrame ack = InitAckFrame(last_packet);
|
| + NackPacket(last_packet - 1, &ack);
|
| + PacketNumberSet lost_packets;
|
| + lost_packets.insert(last_packet - 1);
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| + EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
|
| + .WillOnce(Return(lost_packets));
|
| + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
|
| + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0);
|
| + ProcessAckPacket(&ack);
|
| +
|
| + connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14);
|
| +
|
| + // Unblock the connection and verify that the RST_STREAM is sent and the
|
| + // second data packet or a retransmit is only sent on QUIC_VERSION_29 or
|
| + // later versions.
|
| + if (version() > QUIC_VERSION_28) {
|
| + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
|
| + .Times(AtLeast(2));
|
| + } else {
|
| + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
|
| + }
|
| + writer_->SetWritable();
|
| + connection_.OnCanWrite();
|
| + EXPECT_EQ(1u, writer_->frame_count());
|
| + if (version() > QUIC_VERSION_28) {
|
| + EXPECT_EQ(0u, writer_->rst_stream_frames().size());
|
| + } else {
|
| + EXPECT_EQ(1u, writer_->rst_stream_frames().size());
|
| + EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id);
|
| + }
|
| +}
|
| +
|
| TEST_P(QuicConnectionTest, DiscardRetransmit) {
|
| QuicPacketNumber last_packet;
|
| SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1
|
|
|