diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-09-02 02:45:20 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-02 02:45:20 +0300 |
| commit | cc88b3b8e5bb9f7d9f23ed6ae85a52fd7b5b9ed6 (patch) | |
| tree | 4d37c760099070f1a1488b61c7b7271875aafef8 /tests/live_handoff.rs | |
| parent | 18e69891dca486d669a584facd80644bb51f54a2 (diff) | |
feat: add stable client endpoint compatibility (#3509)
* feat: add stable client endpoint compatibility
* fix: keep portable-pty patch checks composable
* ci: run maintenance checks in pull requests
* fix: reject endpoint errors from terminal clients
* feat: keep compatible servers running across updates
Diffstat (limited to 'tests/live_handoff.rs')
| -rw-r--r-- | tests/live_handoff.rs | 71 |
1 files changed, 39 insertions, 32 deletions
diff --git a/tests/live_handoff.rs b/tests/live_handoff.rs index d58fb301..50b39698 100644 --- a/tests/live_handoff.rs +++ b/tests/live_handoff.rs @@ -14,7 +14,7 @@ use portable_pty::{native_pty_system, Child, CommandBuilder, MasterPty, PtySize} use support::{ cleanup_test_base, client_shell_handshake, register_runtime_dir, register_spawned_herdr_pid, send_client_shell_shift_enter, unregister_spawned_herdr_pid, wait_for_client_shell_bootstrap, - wait_for_message_variant, wait_for_socket, SERVER_MESSAGE_CLIENT_SHELL_SNAPSHOT, + wait_for_message_variant, wait_for_socket, SERVER_MESSAGE_ENDPOINT_CONTROL, SERVER_MESSAGE_SERVER_SHUTDOWN, }; @@ -863,22 +863,17 @@ fn live_handoff_preserves_pane_process_io() { assert_eq!(unsafe { libc::kill(child_pid as libc::pid_t, 0) }, 0); assert_eq!(unsafe { libc::kill(second_child_pid as libc::pid_t, 0) }, 0); - let protocol = request( - &api_socket, - serde_json::json!({"id":"test:protocol","method":"ping","params":{}}), - )["result"]["protocol"] - .as_u64() - .unwrap() as u32; + let endpoint_generation = support::CURRENT_ENDPOINT_PROTOCOL_GENERATION; let mut client_stream = UnixStream::connect(&client_socket).unwrap(); - let (server_protocol, error) = - client_shell_handshake(&mut client_stream, protocol, 54, 23).unwrap(); - assert_eq!(server_protocol, protocol); + let (server_generation, error) = + client_shell_handshake(&mut client_stream, endpoint_generation, 54, 23).unwrap(); + assert_eq!(server_generation, endpoint_generation); assert!(error.is_none(), "client shell handshake failed: {error:?}"); assert!( wait_for_message_variant( &mut client_stream, Duration::from_secs(5), - SERVER_MESSAGE_CLIENT_SHELL_SNAPSHOT, + SERVER_MESSAGE_ENDPOINT_CONTROL, ) .unwrap(), "client shell should receive a complete snapshot before handoff" @@ -953,9 +948,17 @@ fn live_handoff_preserves_pane_process_io() { wait_for_output(&api_socket, &second_pane_id, "second:after-handoff-sec"); let mut reattached_shell = UnixStream::connect(&client_socket).unwrap(); - let (server_protocol, error) = - client_shell_handshake(&mut reattached_shell, protocol, 54, 23).unwrap(); - assert_eq!(server_protocol, protocol); + let (server_generation, error) = client_shell_handshake( + &mut reattached_shell, + support::CURRENT_ENDPOINT_PROTOCOL_GENERATION, + 54, + 23, + ) + .unwrap(); + assert_eq!( + server_generation, + support::CURRENT_ENDPOINT_PROTOCOL_GENERATION + ); assert!(error.is_none(), "reattached client shell failed: {error:?}"); wait_for_client_shell_bootstrap(&mut reattached_shell, Duration::from_secs(5)) .expect("fresh client shell should receive restored snapshot before pane content"); @@ -1030,12 +1033,6 @@ pathlib.Path({received:?}).write_text(data.hex()) )); support::wait_for_file(&ready_marker, Duration::from_secs(5)); - let protocol = request( - &api_socket, - serde_json::json!({"id":"test:protocol","method":"ping","params":{}}), - )["result"]["protocol"] - .as_u64() - .unwrap() as u32; assert_ok(request( &api_socket, serde_json::json!({"id":"test:handoff","method":"server.live_handoff","params":{}}), @@ -1045,9 +1042,17 @@ pathlib.Path({received:?}).write_text(data.hex()) wait_for_socket(&client_socket, Duration::from_secs(5)); let mut client_stream = UnixStream::connect(&client_socket).unwrap(); - let (server_protocol, error) = - client_shell_handshake(&mut client_stream, protocol, 54, 23).unwrap(); - assert_eq!(server_protocol, protocol); + let (server_generation, error) = client_shell_handshake( + &mut client_stream, + support::CURRENT_ENDPOINT_PROTOCOL_GENERATION, + 54, + 23, + ) + .unwrap(); + assert_eq!( + server_generation, + support::CURRENT_ENDPOINT_PROTOCOL_GENERATION + ); assert!(error.is_none(), "client shell handshake failed: {error:?}"); wait_for_client_shell_bootstrap(&mut client_stream, Duration::from_secs(5)) .expect("client shell should receive restored state before sending input"); @@ -1124,12 +1129,6 @@ pathlib.Path({received:?}).write_text(data.hex()) )); support::wait_for_file(&ready_marker, Duration::from_secs(5)); - let protocol = request( - &api_socket, - serde_json::json!({"id":"test:protocol","method":"ping","params":{}}), - )["result"]["protocol"] - .as_u64() - .unwrap() as u32; assert_ok(request( &api_socket, serde_json::json!({"id":"test:handoff","method":"server.live_handoff","params":{}}), @@ -1139,9 +1138,17 @@ pathlib.Path({received:?}).write_text(data.hex()) wait_for_socket(&client_socket, Duration::from_secs(5)); let mut client_stream = UnixStream::connect(&client_socket).unwrap(); - let (server_protocol, error) = - client_shell_handshake(&mut client_stream, protocol, 54, 23).unwrap(); - assert_eq!(server_protocol, protocol); + let (server_generation, error) = client_shell_handshake( + &mut client_stream, + support::CURRENT_ENDPOINT_PROTOCOL_GENERATION, + 54, + 23, + ) + .unwrap(); + assert_eq!( + server_generation, + support::CURRENT_ENDPOINT_PROTOCOL_GENERATION + ); assert!(error.is_none(), "client shell handshake failed: {error:?}"); wait_for_client_shell_bootstrap(&mut client_stream, Duration::from_secs(5)) .expect("client shell should receive restored state before sending input"); |
