Fix bad interaction between various migration CLs

cl/360703267 has caused QuicConnectionTest.EffectivePeerAddressChangeAtServer to fail when the right combination of flags is set, because the test would send PATH_CHALLENGE at ENCRYPTION_INITIAL, which we no longer allow. This CL fixes that, and adds a DCHECK to allow us to catch this kind of test issue sooner.

Additionally, this CL fixes the error message from cl/360703267 which was incorrectly logging numbers instead if the enum's string representation.

This CL only changes logging (or debug builds) so it does not have flag protection.

PiperOrigin-RevId: 360924433
Change-Id: I1556241ad1fefc71b0387d9d9b500603970ce2f8
diff --git a/quic/core/quic_packet_creator.cc b/quic/core/quic_packet_creator.cc
index 9dabd3a..d5f7912 100644
--- a/quic/core/quic_packet_creator.cc
+++ b/quic/core/quic_packet_creator.cc
@@ -1604,6 +1604,21 @@
     return false;
   }
 
+  // Sanity check to ensure we don't send frames at the wrong encryption level.
+  QUICHE_DCHECK(
+      packet_.encryption_level == ENCRYPTION_ZERO_RTT ||
+      packet_.encryption_level == ENCRYPTION_FORWARD_SECURE ||
+      (frame.type != GOAWAY_FRAME && frame.type != WINDOW_UPDATE_FRAME &&
+       frame.type != HANDSHAKE_DONE_FRAME &&
+       frame.type != NEW_CONNECTION_ID_FRAME &&
+       frame.type != MAX_STREAMS_FRAME && frame.type != STREAMS_BLOCKED_FRAME &&
+       frame.type != PATH_RESPONSE_FRAME &&
+       frame.type != PATH_CHALLENGE_FRAME && frame.type != STOP_SENDING_FRAME &&
+       frame.type != MESSAGE_FRAME && frame.type != NEW_TOKEN_FRAME &&
+       frame.type != RETIRE_CONNECTION_ID_FRAME &&
+       frame.type != ACK_FREQUENCY_FRAME))
+      << frame.type << " not allowed at " << packet_.encryption_level;
+
   if (frame.type == STREAM_FRAME) {
     if (MaybeCoalesceStreamFrame(frame.stream_frame)) {
       LogCoalesceStreamFrameStatus(true);