Simplify ConstructMisFramedEncryptedPacket() signature. Both call sites have only one version, so taking a ParsedQuicVersion is a better choice than taking a ParsedQuicVersionVector. This is motivated by the variable |version| being unused in ConstructMisFramedEncryptedPacket(), which causes compilation failure in Envoy, but once I'm at it, it makes sense to make this small improvement. gfe-relnote: n/a, test-only change. PiperOrigin-RevId: 277916457 Change-Id: Ica41b8985510bddbe81dadf9843e0a9620ef3ffe
diff --git a/quic/core/http/quic_spdy_client_session_test.cc b/quic/core/http/quic_spdy_client_session_test.cc index 22e0f52..d5b186c 100644 --- a/quic/core/http/quic_spdy_client_session_test.cc +++ b/quic/core/http/quic_spdy_client_session_test.cc
@@ -533,14 +533,15 @@ // A packet with invalid framing should cause a connection to be closed. TEST_P(QuicSpdyClientSessionTest, InvalidFramedPacketReceived) { - if (GetParam().handshake_protocol == PROTOCOL_TLS1_3) { + const ParsedQuicVersion version = GetParam(); + if (version.handshake_protocol == PROTOCOL_TLS1_3) { // TODO(nharper, b/112643533): Figure out why this test fails when TLS is // enabled and fix it. return; } QuicSocketAddress server_address(TestPeerIPAddress(), kTestPort); QuicSocketAddress client_address(TestPeerIPAddress(), kTestPort); - if (GetParam().KnowsWhichDecrypterToUse()) { + if (version.KnowsWhichDecrypterToUse()) { connection_->InstallDecrypter( ENCRYPTION_FORWARD_SECURE, std::make_unique<NullDecrypter>(Perspective::IS_CLIENT)); @@ -561,10 +562,9 @@ QuicConnectionId source_connection_id = EmptyQuicConnectionId(); QuicFramerPeer::SetLastSerializedServerConnectionId( QuicConnectionPeer::GetFramer(connection_), destination_connection_id); - ParsedQuicVersionVector versions = {GetParam()}; bool version_flag = false; QuicConnectionIdIncluded scid_included = CONNECTION_ID_ABSENT; - if (VersionHasIetfInvariantHeader(GetParam().transport_version)) { + if (VersionHasIetfInvariantHeader(version.transport_version)) { version_flag = true; source_connection_id = destination_connection_id; scid_included = CONNECTION_ID_PRESENT; @@ -572,7 +572,7 @@ std::unique_ptr<QuicEncryptedPacket> packet(ConstructMisFramedEncryptedPacket( destination_connection_id, source_connection_id, version_flag, false, 100, "data", CONNECTION_ID_ABSENT, scid_included, PACKET_4BYTE_PACKET_NUMBER, - &versions, Perspective::IS_SERVER)); + version, Perspective::IS_SERVER)); std::unique_ptr<QuicReceivedPacket> received( ConstructReceivedPacket(*packet, QuicTime::Zero())); EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(1);
diff --git a/quic/core/quic_framer_test.cc b/quic/core/quic_framer_test.cc index 7e72b34..38d222b 100644 --- a/quic/core/quic_framer_test.cc +++ b/quic/core/quic_framer_test.cc
@@ -9279,12 +9279,10 @@ } framer_.SetEncrypter(ENCRYPTION_INITIAL, std::make_unique<NullEncrypter>(framer_.perspective())); - ParsedQuicVersionVector versions; - versions.push_back(framer_.version()); std::unique_ptr<QuicEncryptedPacket> packet(ConstructMisFramedEncryptedPacket( TestConnectionId(), EmptyQuicConnectionId(), false, false, kTestQuicStreamId, kTestString, CONNECTION_ID_PRESENT, - CONNECTION_ID_ABSENT, PACKET_4BYTE_PACKET_NUMBER, &versions, + CONNECTION_ID_ABSENT, PACKET_4BYTE_PACKET_NUMBER, framer_.version(), Perspective::IS_CLIENT)); MockFramerVisitor visitor;
diff --git a/quic/test_tools/quic_test_utils.cc b/quic/test_tools/quic_test_utils.cc index dbc5963..aeb4eee 100644 --- a/quic/test_tools/quic_test_utils.cc +++ b/quic/test_tools/quic_test_utils.cc
@@ -992,7 +992,7 @@ QuicConnectionIdIncluded destination_connection_id_included, QuicConnectionIdIncluded source_connection_id_included, QuicPacketNumberLength packet_number_length, - ParsedQuicVersionVector* versions, + ParsedQuicVersion version, Perspective perspective) { QuicPacketHeader header; header.destination_connection_id = destination_connection_id; @@ -1004,7 +1004,7 @@ header.reset_flag = reset_flag; header.packet_number_length = packet_number_length; header.packet_number = QuicPacketNumber(packet_number); - if (QuicVersionHasLongHeaderLengths((*versions)[0].transport_version) && + if (QuicVersionHasLongHeaderLengths(version.transport_version) && version_flag) { header.retry_token_length_length = VARIABLE_LENGTH_INTEGER_LENGTH_1; header.length_length = VARIABLE_LENGTH_INTEGER_LENGTH_2; @@ -1012,10 +1012,7 @@ QuicFrame frame(QuicStreamFrame(1, false, 0, QuicStringPiece(data))); QuicFrames frames; frames.push_back(frame); - ParsedQuicVersion version = - (versions != nullptr ? *versions : AllSupportedVersions())[0]; - QuicFramer framer(versions != nullptr ? *versions : AllSupportedVersions(), - QuicTime::Zero(), perspective, + QuicFramer framer({version}, QuicTime::Zero(), perspective, kQuicDefaultConnectionIdLength); framer.SetInitialObfuscators(destination_connection_id); EncryptionLevel level =
diff --git a/quic/test_tools/quic_test_utils.h b/quic/test_tools/quic_test_utils.h index 7a88d65..eb3d2e8 100644 --- a/quic/test_tools/quic_test_utils.h +++ b/quic/test_tools/quic_test_utils.h
@@ -162,7 +162,7 @@ QuicConnectionIdIncluded destination_connection_id_included, QuicConnectionIdIncluded source_connection_id_included, QuicPacketNumberLength packet_number_length, - ParsedQuicVersionVector* versions, + ParsedQuicVersion version, Perspective perspective); void CompareCharArraysWithHexError(const std::string& description,