Repository navigation
Conversation
size-limit report 📦
|
Stress results (run)Both test files were run 40 times in each of 4 shards, comparing the fixed-delay versions from
I'll drop the temporary 🤖 Generated with Claude Code |
Replace the 10ms/20ms sleeps that let these tests win a race with vi.waitFor on the condition they are waiting for: - subscriberBlackScreen: wait for the dead transform to be torn down and for the plaintext frame to reach the decoder. - e2ee.worker: record the worker's replies. Wait until the worker has handled its setup messages with a barrier (an `enable` message, which the worker echoes back once every earlier message is through), wait for the encrypted frame, and wait for the MissingKey error before checking that the frame was not decoded.
b721831 to
6965cbd
Compare
| const waitUntilWorkerHasProcessedAllMessages = async () => { | ||
| const participantIdentity = `barrier-${(barrierCount += 1)}`; | ||
| post({ kind: 'enable', data: { enabled: false, participantIdentity } }); | ||
| await vi.waitFor(() => | ||
| expect( | ||
| replies.some( | ||
| (r) => r.kind === 'enable' && r.data.participantIdentity === participantIdentity, | ||
| ), | ||
| ).toBe(true), | ||
| ); | ||
| }; |
There was a problem hiding this comment.
thought: I read this and briefly considered adding a ping / pong types of event s to the e2ee worker, but I think decided it is probably a bit too heavyweight to add something like this just for a test. But I could be convinced otherwise.
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
Follow-up to the review on #2285: replaces fixed 10–20ms sleeps that let tests win a race with
vi.waitForon the condition the test is actually waiting for.Changes
src/e2ee/subscriberBlackScreen.test.tshasActiveTransform()is false instead of sleeping 10ms. (setupTransformsets the transform synchronously and the pipe'sfinallyclears it, so the condition can't be true before the work happens.)src/e2ee/worker/e2ee.worker.test.tspostMessagestub now records the worker's replies.enablemessage for a throwaway identity and wait for its echo. The worker runs messages one at a time through anAsyncQueue, so once the echo arrives every earlier message has been handled.MissingKeyerror foralice, which is a positive sign that the frame was processed and dropped, and then asserts nothing was decoded. I checked that flipping the track to unencrypted still makes this test fail.Not changed
subscriberBlackScreen.test.ts"must not forward ciphertext…" and "drops silently…" also use 10ms sleeps before checking that nothing happened. They need a positive "frame was consumed" signal first (vi.waitForon a negative assertion passes immediately), so they're left for a follow-up.SignalClient.e2e.test.tssleep(4_000): the sleep is the test (stay connected past the server's 3s ping timeout), so there's no condition to poll.Reliability check
A temporary stress workflow, since removed from the branch, ran both files 160 times per setup with the old (main) and new versions. It ran them idle and with vitest pinned to one core alongside 4
stress-ngCPU hogs. The old versions failed all 160 starved runs; the new versions passed every run. See the results comment.The barrier relies on the worker echoing
enablemessages back. That echo is an existing ack the main thread already depends on, so I didn't add a dedicatedping/pongmessage just for tests. If the echo is ever removed,vi.waitFortimes out and the test fails loudly rather than passing silently.🤖 Generated with Claude Code