Parameterize QuicDispatcherTest by version

This CL also improves version handling in quic::test::FullChloGenerator and adds a DCHECK and better logs in production code.

gfe-relnote: n/a, test-only
PiperOrigin-RevId: 295804827
Change-Id: Iecabca01df59444b8149cb696482398d47b407c1
diff --git a/quic/test_tools/crypto_test_utils.cc b/quic/test_tools/crypto_test_utils.cc
index 53b66c8..b599ed7 100644
--- a/quic/test_tools/crypto_test_utils.cc
+++ b/quic/test_tools/crypto_test_utils.cc
@@ -107,6 +107,7 @@
       QuicSocketAddress server_addr,
       QuicSocketAddress client_addr,
       const QuicClock* clock,
+      ParsedQuicVersion version,
       QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config,
       QuicCompressedCertsCache* compressed_certs_cache,
       CryptoHandshakeMessage* out)
@@ -114,6 +115,7 @@
         server_addr_(server_addr),
         client_addr_(client_addr),
         clock_(clock),
+        version_(version),
         signed_config_(signed_config),
         compressed_certs_cache_(compressed_certs_cache),
         out_(out),
@@ -145,9 +147,9 @@
     result_ = result;
     crypto_config_->ProcessClientHello(
         result_, /*reject_only=*/false, TestConnectionId(1), server_addr_,
-        client_addr_, AllSupportedVersions().front(), AllSupportedVersions(),
-        clock_, QuicRandom::GetInstance(), compressed_certs_cache_, params_,
-        signed_config_, /*total_framing_overhead=*/50, kDefaultMaxPacketSize,
+        client_addr_, version_, {version_}, clock_, QuicRandom::GetInstance(),
+        compressed_certs_cache_, params_, signed_config_,
+        /*total_framing_overhead=*/50, kDefaultMaxPacketSize,
         GetProcessClientHelloCallback());
   }
 
@@ -155,12 +157,14 @@
    public:
     explicit ProcessClientHelloCallback(FullChloGenerator* generator)
         : generator_(generator) {}
-    void Run(QuicErrorCode /*error*/,
-             const std::string& /*error_details*/,
+    void Run(QuicErrorCode error,
+             const std::string& error_details,
              std::unique_ptr<CryptoHandshakeMessage> message,
              std::unique_ptr<DiversificationNonce> /*diversification_nonce*/,
              std::unique_ptr<ProofSource::Details> /*proof_source_details*/)
         override {
+      ASSERT_TRUE(message) << QuicErrorCodeToString(error) << " "
+                           << error_details;
       generator_->ProcessClientHelloDone(std::move(message));
     }
 
@@ -200,6 +204,7 @@
   QuicSocketAddress server_addr_;
   QuicSocketAddress client_addr_;
   const QuicClock* clock_;
+  ParsedQuicVersion version_;
   QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config_;
   QuicCompressedCertsCache* compressed_certs_cache_;
   CryptoHandshakeMessage* out_;
@@ -813,21 +818,24 @@
                                                    sizeof(public_value)));
 }
 
-void GenerateFullCHLO(const CryptoHandshakeMessage& inchoate_chlo,
-                      QuicCryptoServerConfig* crypto_config,
-                      QuicSocketAddress server_addr,
-                      QuicSocketAddress client_addr,
-                      QuicTransportVersion version,
-                      const QuicClock* clock,
-                      QuicReferenceCountedPointer<QuicSignedServerConfig> proof,
-                      QuicCompressedCertsCache* compressed_certs_cache,
-                      CryptoHandshakeMessage* out) {
+void GenerateFullCHLO(
+    const CryptoHandshakeMessage& inchoate_chlo,
+    QuicCryptoServerConfig* crypto_config,
+    QuicSocketAddress server_addr,
+    QuicSocketAddress client_addr,
+    QuicTransportVersion transport_version,
+    const QuicClock* clock,
+    QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config,
+    QuicCompressedCertsCache* compressed_certs_cache,
+    CryptoHandshakeMessage* out) {
   // Pass a inchoate CHLO.
-  FullChloGenerator generator(crypto_config, server_addr, client_addr, clock,
-                              proof, compressed_certs_cache, out);
+  FullChloGenerator generator(
+      crypto_config, server_addr, client_addr, clock,
+      ParsedQuicVersion(PROTOCOL_QUIC_CRYPTO, transport_version), signed_config,
+      compressed_certs_cache, out);
   crypto_config->ValidateClientHello(
-      inchoate_chlo, client_addr.host(), server_addr, version, clock, proof,
-      generator.GetValidateClientHelloCallback());
+      inchoate_chlo, client_addr.host(), server_addr, transport_version, clock,
+      signed_config, generator.GetValidateClientHelloCallback());
 }
 
 }  // namespace crypto_test_utils
diff --git a/quic/test_tools/crypto_test_utils.h b/quic/test_tools/crypto_test_utils.h
index 2765004..d80210a 100644
--- a/quic/test_tools/crypto_test_utils.h
+++ b/quic/test_tools/crypto_test_utils.h
@@ -185,7 +185,7 @@
     QuicCryptoServerConfig* crypto_config,
     QuicSocketAddress server_addr,
     QuicSocketAddress client_addr,
-    QuicTransportVersion version,
+    QuicTransportVersion transport_version,
     const QuicClock* clock,
     QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config,
     QuicCompressedCertsCache* compressed_certs_cache,