Rewrite QuicTypesTest.QuicIetfTransportErrorCodeString. This test did not make any sense. It enforced that internal QuicErrorCodes beyond QUIC_PACKET_TOO_LARGE did not map to defined IETF on-the-wire error codes. This is contradictory to our efforts to send an IETF-compliant error code for each QuicErrorCodes code. gfe-relnote: n/a, test-only change. PiperOrigin-RevId: 300394002 Change-Id: I054df8252e8ebb9238ff4fffab1b08632e5bba24
diff --git a/quic/core/quic_types_test.cc b/quic/core/quic_types_test.cc index 63ebdb0..dc37c43 100644 --- a/quic/core/quic_types_test.cc +++ b/quic/core/quic_types_test.cc
@@ -6,9 +6,9 @@ #include <cstdint> +#include "third_party/boringssl/src/include/openssl/ssl.h" #include "net/third_party/quiche/src/quic/core/quic_error_codes.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" namespace quic { namespace test { @@ -17,21 +17,43 @@ class QuicTypesTest : public QuicTest {}; TEST_F(QuicTypesTest, QuicIetfTransportErrorCodeString) { - // QuicIetfTransportErrorCode out of bound. - for (quic::QuicErrorCode error = quic::QUIC_PACKET_TOO_LARGE; - error < quic::QUIC_LAST_ERROR; - error = static_cast<quic::QuicErrorCode>(error + 1)) { - QuicErrorCodeToIetfMapping mapping = - QuicErrorCodeToTransportErrorCode(error); - if (mapping.is_transport_close_) { - EXPECT_EQ(QuicIetfTransportErrorCodeString(mapping.transport_error_code_), - quiche::QuicheStrCat( - "Unknown(", - static_cast<uint64_t>(mapping.transport_error_code_), ")")) - << " " << static_cast<uint64_t>(error) << " " - << QuicErrorCodeToString(error); - } - } + EXPECT_EQ("Private(65280)", + QuicIetfTransportErrorCodeString( + static_cast<quic::QuicIetfTransportErrorCodes>(0xff00u))); + + EXPECT_EQ("CRYPTO_ERROR(missing extension)", + QuicIetfTransportErrorCodeString( + static_cast<quic::QuicIetfTransportErrorCodes>( + CRYPTO_ERROR_FIRST + SSL_AD_MISSING_EXTENSION))); + + EXPECT_EQ("NO_IETF_QUIC_ERROR", + QuicIetfTransportErrorCodeString(NO_IETF_QUIC_ERROR)); + EXPECT_EQ("INTERNAL_ERROR", QuicIetfTransportErrorCodeString(INTERNAL_ERROR)); + EXPECT_EQ("SERVER_BUSY_ERROR", + QuicIetfTransportErrorCodeString(SERVER_BUSY_ERROR)); + EXPECT_EQ("FLOW_CONTROL_ERROR", + QuicIetfTransportErrorCodeString(FLOW_CONTROL_ERROR)); + EXPECT_EQ("STREAM_LIMIT_ERROR", + QuicIetfTransportErrorCodeString(STREAM_LIMIT_ERROR)); + EXPECT_EQ("STREAM_STATE_ERROR", + QuicIetfTransportErrorCodeString(STREAM_STATE_ERROR)); + EXPECT_EQ("FINAL_SIZE_ERROR", + QuicIetfTransportErrorCodeString(FINAL_SIZE_ERROR)); + EXPECT_EQ("FRAME_ENCODING_ERROR", + QuicIetfTransportErrorCodeString(FRAME_ENCODING_ERROR)); + EXPECT_EQ("TRANSPORT_PARAMETER_ERROR", + QuicIetfTransportErrorCodeString(TRANSPORT_PARAMETER_ERROR)); + EXPECT_EQ("CONNECTION_ID_LIMIT_ERROR", + QuicIetfTransportErrorCodeString(CONNECTION_ID_LIMIT_ERROR)); + EXPECT_EQ("PROTOCOL_VIOLATION", + QuicIetfTransportErrorCodeString(PROTOCOL_VIOLATION)); + EXPECT_EQ("INVALID_TOKEN", QuicIetfTransportErrorCodeString(INVALID_TOKEN)); + EXPECT_EQ("CRYPTO_BUFFER_EXCEEDED", + QuicIetfTransportErrorCodeString(CRYPTO_BUFFER_EXCEEDED)); + + EXPECT_EQ("Unknown(1024)", + QuicIetfTransportErrorCodeString( + static_cast<quic::QuicIetfTransportErrorCodes>(0x400))); } } // namespace