From 42f2d4a6caad856cb457903f60ee298c9510a53e Mon Sep 17 00:00:00 2001 From: Mark Xue Date: Thu, 24 Sep 2026 21:31:24 -0700 Subject: [PATCH] Fix flaky sealed-frame first-byte assertion in session test A header-sealed frame's first byte is a random nonce byte, so assert_ne!(welcome_b.first(), Some(&APQ_TAG)) had a 1/256 chance of matching the plaintext tag and failing CI. Replace it with a deterministic check that the plaintext welcome doesn't appear in the sealed frame, mirroring the envelope check earlier in the same test. Co-Authored-By: Claude Sonnet 5 --- .changeset/fix-flaky-sealed-welcome-test.md | 4 ++++ rust/two-mls-pq/src/session/tests.rs | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 .changeset/fix-flaky-sealed-welcome-test.md diff --git a/.changeset/fix-flaky-sealed-welcome-test.md b/.changeset/fix-flaky-sealed-welcome-test.md new file mode 100644 index 0000000..0553d6b --- /dev/null +++ b/.changeset/fix-flaky-sealed-welcome-test.md @@ -0,0 +1,4 @@ +--- +--- + +Test-only: replace a flaky first-byte check on a header-sealed frame with a plaintext-absence check; nothing ships. diff --git a/rust/two-mls-pq/src/session/tests.rs b/rust/two-mls-pq/src/session/tests.rs index 2a604e2..e916810 100644 --- a/rust/two-mls-pq/src/session/tests.rs +++ b/rust/two-mls-pq/src/session/tests.rs @@ -5239,10 +5239,14 @@ fn test_initial_envelope_roundtrip_return_welcome_sealed() { // Bob's return welcome is symmetric-sealed (Bob has the recv group) and opens on // Alice's window to the APQWelcome. let welcome_b = assert_some!(bob_s.pending_outbound()); - assert_ne!(welcome_b.first(), Some(&super::APQ_TAG)); - assert_eq!( - open_frame(&alice_s, &welcome_b).first(), - Some(&super::APQ_TAG) + let plaintext_welcome_b = open_frame(&alice_s, &welcome_b); + assert_eq!(plaintext_welcome_b.first(), Some(&super::APQ_TAG)); + // Not a first-byte check: offset 0 of a sealed frame is a random nonce, so it + // equals any given tag once in 256 draws. + let n = plaintext_welcome_b.len().min(16); + assert!( + !welcome_b.windows(n).any(|w| w == &plaintext_welcome_b[..n]), + "the plaintext welcome must not appear in the sealed frame" ); }