From 83b9f54c0f64e2e084661fc6b1625c2a3e502b66 Mon Sep 17 00:00:00 2001 From: diffwireauto <330573775+diffwireauto@users.noreply.github.com> Date: Sun, 4 Oct 2026 00:29:58 -0400 Subject: [PATCH] fix(#782): connect scenario waits for the handshake instead of sampling it Found in Epic C verification: one parallel run of test/fake_radio failed "stock over TCP" because SET_DEVICE_TIME hadn't reached the fake yet. connectTcp's closing syncTime() only queues the frame on the socket, so it can land just after the channel and contact data the test waited for. The test now waits for every handshake command to arrive. 5 consecutive full fake-radio runs clean (136 tests each). Co-Authored-By: Claude Opus 5.5 --- test/fake_radio/connect_scenario_test.dart | 25 ++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/test/fake_radio/connect_scenario_test.dart b/test/fake_radio/connect_scenario_test.dart index 8398e4eb..5d82364c 100644 --- a/test/fake_radio/connect_scenario_test.dart +++ b/test/fake_radio/connect_scenario_test.dart @@ -71,18 +71,21 @@ void main() { what: 'contacts', ); // The data came from the radio: the handshake really ran against it. - final codes = radio.received.map((f) => f[0]).toSet(); - expect( - codes, - containsAll([ - fwCmdDeviceQuery, - fwCmdAppStart, - fwCmdSetDeviceTime, - fwCmdGetChannel, - fwCmdSyncNextMessage, - fwCmdGetContacts, - ]), + // Waited for, not sampled: over TCP a sent frame is only queued, so the + // closing SET_DEVICE_TIME can land just after the sync data does. + const handshake = [ + fwCmdDeviceQuery, + fwCmdAppStart, + fwCmdSetDeviceTime, + fwCmdGetChannel, + fwCmdSyncNextMessage, + fwCmdGetContacts, + ]; + await _until( + () => radio.received.map((f) => f[0]).toSet().containsAll(handshake), + what: 'the handshake commands at the radio', ); + final codes = radio.received.map((f) => f[0]).toSet(); // What the client concluded about the firmware matches the profile. if (radio.profile.offband) { expect(connector.offbandCaps, radio.profile.offbandCaps);