gfe-relnote: (n/a) In QuicClientBase, mark version negotiated when the client reconnects. Test only.

This is an attempt to deflake test SimpleRequestResponseZeroConnectionID and ZeroConnectionID.

PiperOrigin-RevId: 293356478
Change-Id: I63bbed4fde7a9fe71a1100660c7c82750c0bf74f
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc
index 246d9d9..a8a269c 100644
--- a/quic/core/quic_connection.cc
+++ b/quic/core/quic_connection.cc
@@ -384,8 +384,7 @@
   // On the server side, version negotiation has been done by the dispatcher,
   // and the server connection is created with the right version.
   if (perspective_ == Perspective::IS_SERVER) {
-    version_negotiated_ = true;
-    framer_.InferPacketHeaderTypeFromVersion();
+    SetVersionNegotiated();
   }
 }
 
diff --git a/quic/core/quic_connection.h b/quic/core/quic_connection.h
index 56d88a3..b932164 100644
--- a/quic/core/quic_connection.h
+++ b/quic/core/quic_connection.h
@@ -484,6 +484,15 @@
     return framer_.supported_versions();
   }
 
+  // Mark version negotiated for this connection. Once called, the connection
+  // will ignore received version negotiation packets.
+  void SetVersionNegotiated() {
+    version_negotiated_ = true;
+    if (perspective_ == Perspective::IS_SERVER) {
+      framer_.InferPacketHeaderTypeFromVersion();
+    }
+  }
+
   // From QuicFramerVisitorInterface
   void OnError(QuicFramer* framer) override;
   bool OnProtocolVersionMismatch(ParsedQuicVersion received_version) override;
diff --git a/quic/tools/quic_client_base.cc b/quic/tools/quic_client_base.cc
index 9249ddc..e924c46 100644
--- a/quic/tools/quic_client_base.cc
+++ b/quic/tools/quic_client_base.cc
@@ -79,8 +79,7 @@
       WaitForEvents();
     }
     ParsedQuicVersion version = UnsupportedQuicVersion();
-    if (session() != nullptr &&
-        !CanReconnectWithDifferentVersion(&version)) {
+    if (session() != nullptr && !CanReconnectWithDifferentVersion(&version)) {
       // We've successfully created a session but we're not connected, and we
       // cannot reconnect with a different version.  Give up trying.
       break;
@@ -126,6 +125,10 @@
   // session.
   set_writer(writer);
   InitializeSession();
+  if (can_reconnect_with_different_version) {
+    // This is a reconnect using server supported |mutual_version|.
+    session()->connection()->SetVersionNegotiated();
+  }
   set_connected_or_attempting_connect(true);
 }