Skip to content

The agent that grows with you

test(environments): trim payload-stdin tests to two invariants

kshitijk4poor643e3f4ff506
diff --git a/tests/tools/test_daytona_environment.py b/tests/tools/test_daytona_environment.py
index 595d6cc0277..860dc9941e6 100644
--- a/tests/tools/test_daytona_environment.py
+++ b/tests/tools/test_daytona_environment.py
@@ -193,64 +193,6 @@ class TestExecute:
assert "hello" in result["output"]
assert result["returncode"] == 0
- def test_cancel_cleans_staged_stdin_before_stopping(self, make_env):
- env = make_env()
- sandbox = env._sandbox
- sandbox.process.exec.reset_mock()
- started = threading.Event()
- release = threading.Event()
-
- def exec_side_effect(command, **kwargs):
- if "cat > /tmp/payload.txt" in command:
- started.set()
- release.wait(timeout=5)
- return _make_exec_response(result="", exit_code=0)
-
- sandbox.process.exec.side_effect = exec_side_effect
- handle = env._run_bash("cat > /tmp/payload.txt", stdin_data="secret")
- assert started.wait(timeout=1)
-
- handle.kill()
- release.set()
-
- assert handle.wait(timeout=2) == 0
- sandbox.fs.delete_file.assert_called()
- deleted_path = sandbox.fs.delete_file.call_args.args[0]
- assert ".hermes-stdin-" in deleted_path
- assert sandbox.fs.delete_file.call_args.kwargs["request_timeout"] == 5
- sandbox.stop.assert_called()
-
- def test_large_stdin_is_staged_outside_command_argv(self, make_env):
- env = make_env()
- sandbox = env._sandbox
- sandbox.process.exec.reset_mock()
- sandbox.process.exec.return_value = _make_exec_response(result="ok", exit_code=0)
- uploads = []
-
- def capture_upload(host_path, remote_path):
- with open(host_path, "rb") as staged:
- uploads.append((remote_path, staged.read()))
-
- sandbox.fs.upload_file.side_effect = capture_upload
- expected = (b"A" * (160 * 1024)) + b"\x00\xff\xfeTAIL"
- payload = expected.decode("utf-8", "surrogateescape")
-
- handle = env._run_bash("cat > /tmp/payload.txt", stdin_data=payload)
-
- assert handle.wait(timeout=2) == 0
- assert env._stdin_mode == "payload"
- assert uploads and uploads[0][1] == expected
- assert sandbox.fs.set_file_permissions.call_args.args[0] == uploads[0][0]
- assert sandbox.fs.set_file_permissions.call_args.kwargs["mode"] == "600"
- shell_cmd = next(
- call.args[0] for call in sandbox.process.exec.call_args_list
- if "cat > /tmp/payload.txt" in call.args[0]
- )
- assert payload not in shell_cmd
- assert ".hermes-stdin-" in shell_cmd
- assert shell_cmd.index("exec 0<") < shell_cmd.index("rm -f --")
- assert shell_cmd.index("rm -f --") < shell_cmd.index("cat > /tmp/payload.txt")
-
diff --git a/tests/tools/test_file_write_surrogate_roundtrip.py b/tests/tools/test_file_write_surrogate_roundtrip.py
index 4ba02f9ddd8..0df0f57e86b 100644
--- a/tests/tools/test_file_write_surrogate_roundtrip.py
+++ b/tests/tools/test_file_write_surrogate_roundtrip.py
@@ -115,21 +115,6 @@ def test_payload_mode_write_is_byte_exact_beyond_argv_limit(tmp_path):
assert max(len(command.encode("utf-8")) for command in env.spawn_commands) < 128 * 1024
-def test_payload_mode_feeds_compound_reads_and_preserves_status(tmp_path):
- """Base passes the merged payload stream unchanged to backend-owned stdin transport."""
- env = _PayloadLocalEnvironment(str(tmp_path))
-
- result = env.execute(
- 'IFS= read -r first; IFS= read -r second; '
- 'printf "<%s|%s>" "$first" "$second"; exit 7',
- stdin_data="pw\npayload",
- )
-
- assert result["returncode"] == 7
- assert "<pw|payload>" in result["output"]
-
-
@pytest.fixture
def env(tmp_path):
"""A real LocalEnvironment rooted in a temp directory."""
diff --git a/tests/tools/test_vercel_sandbox_environment.py b/tests/tools/test_vercel_sandbox_environment.py
index 1561de004ed..4b2694ce8b5 100644
--- a/tests/tools/test_vercel_sandbox_environment.py
+++ b/tests/tools/test_vercel_sandbox_environment.py
@@ -523,63 +523,6 @@ class TestExecute:
assert args == ["-c", "echo done"]
assert kwargs["cwd"] == "/vercel/sandbox"
- def test_cancel_stops_without_dispatching_cleanup_command(
- self, make_env, vercel_sdk
- ):
- env = make_env()
- sandbox = vercel_sdk.current
- sandbox.run_command_calls.clear()
- started = threading.Event()
- release = threading.Event()
-
- def blocking_command(_cmd: str, _args: list[str], _kwargs: dict):
- started.set()
- release.wait(timeout=5)
- return _FakeRunResult("")
-
- sandbox.run_command_side_effects.append(blocking_command)
- handle = env._run_bash("cat > /tmp/payload.txt", stdin_data="secret")
- assert started.wait(timeout=1)
-
- handle.kill()
- release.set()
-
- assert handle.wait(timeout=2) == 0
- # kill() must not dispatch another potentially unbounded SDK command.
- user_calls = [
- (cmd, args) for cmd, args, _ in sandbox.run_command_calls
- if cmd == "bash" and len(args) > 1 and "cat > /tmp/payload.txt" in args[1]
- ]
- assert len(user_calls) == 1
- assert len(sandbox.stop_calls) == 1
-
- def test_large_stdin_is_staged_outside_command_argv(
- self, make_env, vercel_sdk
- ):
- env = make_env()
- sandbox = vercel_sdk.current
- sandbox.run_command_calls.clear()
- sandbox.write_files_calls.clear()
- expected = (b"A" * (160 * 1024)) + b"\x00\xff\xfeTAIL"
- payload = expected.decode("utf-8", "surrogateescape")
-
- handle = env._run_bash("cat > /tmp/payload.txt", stdin_data=payload)
-
- assert handle.wait(timeout=2) == 0
- assert env._stdin_mode == "payload"
- assert sandbox.write_files_calls
- staged = sandbox.write_files_calls[0][0]
- assert staged["content"] == expected
- assert staged["mode"] == 0o600
- command = next(
- args[1] for cmd, args, _ in sandbox.run_command_calls
- if cmd == "bash" and len(args) > 1 and "cat > /tmp/payload.txt" in args[1]
- )
- assert payload not in command
- assert ".hermes-stdin-" in command
- assert command.index("exec 0<") < command.index("rm -f --")
- assert command.index("rm -f --") < command.index("cat > /tmp/payload.txt")
-
class TestSnapshotPersistence:
def test_create_restores_from_saved_snapshot(