Repository navigation
test(computers): wait for both pairing handshakes - #575
Merged
Merged
Conversation
Force the listener-connected/dialler-metadata-pending ordering and wait for each gateway to commit its own handshake before asserting saved versions. Related: #573
nixuuu
marked this pull request as ready for review
November 12, 2026 16:36
nixuuu
added a commit
that referenced
this pull request
Nov 12, 2026
The pairing suite could leave a deliberately persisted `pairing_required` untouched when restoring the original peer. Its shared fixture starts the runtime before the listener (`tests/integration/support/computers.ts:42`), so a startup dial races the listener's first address announcement. That announcement retires sockets and aborts dials (`apps/gateway/src/computers/runtime-lan.ts:51`). The suite's single reconnect tick can observe the closing incoming connection and skip dialing (`apps/gateway/src/computers/runtime-connection.ts:149`); its next automatic retry is deliberately 60 seconds away, beyond the 5-second assertion window. This is fixture timing. The #579 failure occurs in `restoreB()`, after the test intentionally sets `pairing_required`, not in shared setup or a previous test. The failed job shows two expected `server_pin_mismatch` probes followed by an aborted startup connection and no subsequent successful handshake. Self-heal writes `connected` only after a successful pinned handshake (`apps/gateway/src/computers/runtime-frames.ts:316–321`). There is no evidence here of that write being overwritten. Pause dialing during fixture startup until its listener and initial address publication have completed. Explicit ticks then establish links, and shared setup/recovery wait for each gateway's own committed connected status. Preserve the cross-version metadata barrier, remove its route-deletion workaround, and extend the persisted-state recovery case with a barrier holding listener startup open. Validation: - With the previous startup helper, the controlled barrier fails deterministically: expected zero startup dials, received one. - Five consecutive complete file runs with `TMPDIR=/var/tmp nice -n 19 bun run check:tmp ./tests/integration/linked-pairing-recovery.test.ts`: **10 passed, 0 failed each time** (50 test executions), each about 4.4 seconds; every temp-directory check passed. - Changed-file formatting, lint and `git diff --check` pass. No other local tests run. - Pending: two complete consecutive green CI attempts on the same head, rerunning the entire workflow once. Related: #573 Related: #575 Related: #579
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The cross-version pairing recovery test read B's saved version immediately after observing A's
connectedstatus. In both failed #573 runs it expected0.2.0-nightly.137and received the pairing-time0.0.0-dev. A can finish processing B's hello while B is still processing A's welcome, so A's status is not a barrier for B's database write.This is test timing. Each side already awaits its hello metadata write before publishing its own connected status. A queues its welcome before that status write; completion across the two independent gateways is asynchronous.
Let the online helper wait for a specified peer/store, and wait for both sides before reading their final versions. Add a controlled barrier around B's metadata write and force the B → A dial after listener startup. The test now proves A can be connected while B still holds the old version, releases B, then waits for B's own connected commit. It retains the trust, protocol, version and upgraded-capability assertions. No sleeps, larger timeouts or assertion retries were added to hide the ordering.
Evidence from the original failures: attempt 1 / job 131276846769, attempt 2 / job 131286358670, both at
linked-pairing-recovery.test.ts:267.Validation on the authorized file only, sequentially with
TMPDIR=/var/tmp nice -n 19 bun run check:tmp:--rerun-each 10: 10 passed, temp directory clean.git diff --checkpassed.Required CI validation: two complete consecutive green attempts for the same head, rerunning the entire workflow once after the first green result. This is pending; local repetition is not counted as CI evidence.
Related: #573