From c54d5b15aa3132b37f712a4a1ac2e3ca713cb090 Mon Sep 17 00:00:00 2001 From: Evgeniy Kovrov <7254010+nyxene@users.noreply.github.com> Date: Sun, 25 Oct 2026 23:50:32 +0100 Subject: [PATCH 1/2] test: the lost-link fake cuts the link only after the client has the armed marker The fake ssh in `lost` mode killed the relay on a fixed one-second timer. When the relay took longer than that to start, connect and forward the marker (a freshly built binary pays about half a second on its first exec, more under a full gates run), the client saw no byte and rightly reported an ssh failure. The fake now waits for the client to see the marker, so the test always proves what its name says. Closes #141 Co-Authored-By: Claude --- src/client.rs | 7 ++++++- tests/fixtures/fake-ssh | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/client.rs b/src/client.rs index a69ceca..0f9a737 100644 --- a/src/client.rs +++ b/src/client.rs @@ -2077,7 +2077,12 @@ mod remote_tests { // As the real client: a relay that fails at once may close the pipe before Hello. let _ = hello().write_to(&mut stdin); let mut screen = Vec::new(); - let seen = pump(Vec::new(), stdout, &mut screen, false, |_| {}); + // The `lost` fake cuts the link only once the client has the marker. + let seen = pump(Vec::new(), stdout, &mut screen, false, |r| { + if r.armed { + let _ = std::fs::write(self.dir.join("armed"), ""); + } + }); drop(stdin); let (exit, said) = finish(child, stderr); (seen, screen, exit, said) diff --git a/tests/fixtures/fake-ssh b/tests/fixtures/fake-ssh index 9b4831c..24975c1 100755 --- a/tests/fixtures/fake-ssh +++ b/tests/fixtures/fake-ssh @@ -21,11 +21,11 @@ case $last in unset NERD_SOCKET NERD_INSTANCE export NERD_STATE_DIR="$dir/state" HOME="$dir" if [ "$mode" = lost ]; then - # The link drops a second in: the relay dies with no word, ssh exits 255. + # The link drops once the client has the armed marker: the relay dies with no word, ssh exits 255. "$dir/nerd" --relay "$id" <&0 & pid=$! - sleep 1 - kill -9 $pid + while [ ! -e "$dir/armed" ] && kill -0 $pid 2>/dev/null; do sleep 0.05; done + kill -9 $pid 2>/dev/null : > "$dir/ended" exit 255 fi From ace1c319ece498f20ee182daaafb6d2c18ec85b3 Mon Sep 17 00:00:00 2001 From: Evgeniy Kovrov <7254010+nyxene@users.noreply.github.com> Date: Mon, 26 Oct 2026 13:23:20 +0100 Subject: [PATCH 2/2] test: the lost-link stand-in server stays open until the client has the marker, not for a fixed 3 s Part of #141 Co-Authored-By: Claude --- src/client.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/client.rs b/src/client.rs index 0f9a737..0426344 100644 --- a/src/client.rs +++ b/src/client.rs @@ -2278,8 +2278,14 @@ mod remote_tests { #[test] fn a_link_that_dies_after_the_arming_is_a_loss() { let fake = Fake::new("lost", "lost"); - let server = fake.serve(|s| { + let armed = fake.dir.join("armed"); + let server = fake.serve(move |s| { s.write_all(ARMED).unwrap(); + // Open until the client has the marker, however slow the machine, then long enough for the fake ssh to cut the link. + let t = std::time::Instant::now(); + while !armed.exists() && t.elapsed() < Duration::from_secs(60) { + std::thread::sleep(Duration::from_millis(20)); + } std::thread::sleep(Duration::from_secs(3)); }); let (seen, _, exit, said) = fake.run("1");