Add helper functions for PROTOCOL_QUIC_CRYPTO versions.

gfe-relnote: n/a (add functions that are currently only used in tests)
PiperOrigin-RevId: 298882420
Change-Id: If759ab3850d8054a257d3129cfb2c2bccf155a1f
diff --git a/quic/core/quic_versions.cc b/quic/core/quic_versions.cc
index 3458c99..9cccff9 100644
--- a/quic/core/quic_versions.cc
+++ b/quic/core/quic_versions.cc
@@ -229,6 +229,28 @@
   return out;
 }
 
+ParsedQuicVersionVector AllSupportedVersionsWithQuicCrypto() {
+  ParsedQuicVersionVector versions;
+  for (const ParsedQuicVersion& version : AllSupportedVersions()) {
+    if (version.handshake_protocol == PROTOCOL_QUIC_CRYPTO) {
+      versions.push_back(version);
+    }
+  }
+  QUIC_BUG_IF(versions.empty()) << "No version with QUIC crypto found.";
+  return versions;
+}
+
+ParsedQuicVersionVector CurrentSupportedVersionsWithQuicCrypto() {
+  ParsedQuicVersionVector versions;
+  for (const ParsedQuicVersion& version : CurrentSupportedVersions()) {
+    if (version.handshake_protocol == PROTOCOL_QUIC_CRYPTO) {
+      versions.push_back(version);
+    }
+  }
+  QUIC_BUG_IF(versions.empty()) << "No version with QUIC crypto found.";
+  return versions;
+}
+
 ParsedQuicVersion ParseQuicVersionLabel(QuicVersionLabel version_label) {
   for (const ParsedQuicVersion& version : AllSupportedVersions()) {
     if (version_label == CreateQuicVersionLabel(version)) {
diff --git a/quic/core/quic_versions.h b/quic/core/quic_versions.h
index bc15354..3151fa2 100644
--- a/quic/core/quic_versions.h
+++ b/quic/core/quic_versions.h
@@ -363,6 +363,18 @@
 QUIC_EXPORT_PRIVATE ParsedQuicVersionVector
 FilterSupportedVersions(ParsedQuicVersionVector versions);
 
+// Returns a subset of AllSupportedVersions() with
+// handshake_protocol == PROTOCOL_QUIC_CRYPTO, in the same order.
+// Deprecated; only to be used in components that do not yet support
+// PROTOCOL_TLS1_3.
+ParsedQuicVersionVector AllSupportedVersionsWithQuicCrypto();
+
+// Returns a subset of CurrentSupportedVersions() with
+// handshake_protocol == PROTOCOL_QUIC_CRYPTO, in the same order.
+// Deprecated; only to be used in components that do not yet support
+// PROTOCOL_TLS1_3.
+ParsedQuicVersionVector CurrentSupportedVersionsWithQuicCrypto();
+
 // Returns QUIC version of |index| in result of |versions|. Returns
 // QUIC_VERSION_UNSUPPORTED if |index| is out of bounds.
 QUIC_EXPORT_PRIVATE QuicTransportVersionVector
diff --git a/quic/qbone/qbone_client_test.cc b/quic/qbone/qbone_client_test.cc
index 813d05b..a41e6a9 100644
--- a/quic/qbone/qbone_client_test.cc
+++ b/quic/qbone/qbone_client_test.cc
@@ -34,11 +34,8 @@
 ParsedQuicVersionVector GetTestParams() {
   ParsedQuicVersionVector test_versions;
 
-  for (const auto& version : CurrentSupportedVersions()) {
-    // TODO(b/113130636): Make QBONE work with TLS.
-    if (version.handshake_protocol == PROTOCOL_TLS1_3) {
-      continue;
-    }
+  // TODO(b/113130636): Make QBONE work with TLS.
+  for (const auto& version : CurrentSupportedVersionsWithQuicCrypto()) {
     // QBONE requires MESSAGE frames
     if (!version.SupportsMessageFrames()) {
       continue;
diff --git a/quic/qbone/qbone_session_test.cc b/quic/qbone/qbone_session_test.cc
index c3219e5..629d281 100644
--- a/quic/qbone/qbone_session_test.cc
+++ b/quic/qbone/qbone_session_test.cc
@@ -47,11 +47,8 @@
 ParsedQuicVersionVector GetTestParams() {
   ParsedQuicVersionVector test_versions;
 
-  for (const auto& version : CurrentSupportedVersions()) {
-    // TODO(b/113130636): Make QBONE work with TLS.
-    if (version.handshake_protocol == PROTOCOL_TLS1_3) {
-      continue;
-    }
+  // TODO(b/113130636): Make QBONE work with TLS.
+  for (const auto& version : CurrentSupportedVersionsWithQuicCrypto()) {
     // QBONE requires MESSAGE frames
     if (!version.SupportsMessageFrames()) {
       continue;
diff --git a/quic/quartc/quartc_stream_test.cc b/quic/quartc/quartc_stream_test.cc
index f1de032..7a8b22d 100644
--- a/quic/quartc/quartc_stream_test.cc
+++ b/quic/quartc/quartc_stream_test.cc
@@ -47,19 +47,6 @@
 
 static const QuicStreamId kStreamId = 5;
 
-ParsedQuicVersionVector GetTestParams() {
-  ParsedQuicVersionVector test_versions;
-
-  for (const auto& version : CurrentSupportedVersions()) {
-    // TODO(b/150224094): Enable versions with TLS handshake.
-    if (version.handshake_protocol != PROTOCOL_TLS1_3) {
-      test_versions.push_back(version);
-    }
-  }
-
-  return test_versions;
-}
-
 // MockQuicSession that does not create streams and writes data from
 // QuicStream to a string.
 class MockQuicSession : public QuicSession {
@@ -285,10 +272,12 @@
   MockClock clock_;
 };
 
-INSTANTIATE_TEST_SUITE_P(Tests,
-                         QuartcStreamTest,
-                         ::testing::ValuesIn(GetTestParams()),
-                         ::testing::PrintToStringParamName());
+// TODO(b/150224094): Enable versions with TLS handshake.
+INSTANTIATE_TEST_SUITE_P(
+    Tests,
+    QuartcStreamTest,
+    ::testing::ValuesIn(CurrentSupportedVersionsWithQuicCrypto()),
+    ::testing::PrintToStringParamName());
 
 // Write an entire string.
 TEST_P(QuartcStreamTest, WriteDataWhole) {