Files
OpenJarvis/tests/sandbox/test_wasm_runner.py
T
Jon Saad-FalconandClaude Opus 4.6 a4c4081ff4 Add desktop distribution pipeline: rolling releases, auto-updates, code signing
- Rewrite .github/workflows/desktop.yml: 2-job pipeline (validate + build-and-release)
  with rolling desktop-latest pre-release on push to main and stable desktop-v* releases
- Add UpdateChecker component: checks for updates on startup + every 30 min,
  background download with progress bar, one-click relaunch
- Configure Tauri updater: endpoints pointing to desktop-latest release, pubkey placeholder
- Add tauri-plugin-process for relaunch support (Cargo.toml, lib.rs, package.json)
- Add macOS Entitlements.plist for notarization (network + file access, no sandbox)
- Add scripts/bump-desktop-version.sh for atomic version bumps across 3 config files
- Add desktop/README.md with dev setup, auto-update architecture, signing docs
- Update .gitignore for desktop/node_modules, dist, target
- Configure macOS minimumSystemVersion, Windows timestampUrl
- Include all Phase 14-21 work: agent hardening, RBAC, taint tracking, workflows,
  skills, knowledge graph, sessions, A2A, MCP templates, WASM sandbox, TUI dashboard,
  production tools, CLI expansion, API expansion, learning productionization,
  Tauri desktop app, and 10 new channels

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 19:14:05 +00:00

59 lines
1.8 KiB
Python

"""Tests for WASM sandbox (Phase 16.4)."""
from __future__ import annotations
import pytest
from openjarvis.sandbox.wasm_runner import WasmResult, WasmRunner, create_sandbox_runner
class TestWasmRunner:
def test_runner_creation(self):
runner = WasmRunner(fuel_limit=500_000, memory_limit_mb=128, timeout=10)
assert runner._fuel_limit == 500_000
def test_available_check(self):
result = WasmRunner.available()
assert isinstance(result, bool)
@pytest.mark.skipif(
not WasmRunner.available(),
reason="wasmtime not installed",
)
def test_validate_invalid_bytes(self):
runner = WasmRunner()
assert not runner.validate(b"not wasm")
def test_run_without_wasmtime(self):
runner = WasmRunner()
if not runner.available():
result = runner.run(b"fake wasm")
assert not result.success
assert "wasmtime" in result.output.lower()
def test_wasm_result_dataclass(self):
result = WasmResult(success=True, output="done", duration_seconds=0.1)
assert result.success
assert result.output == "done"
assert result.duration_seconds == 0.1
class TestCreateSandboxRunner:
def test_factory_returns_something(self):
# Should return either a WasmRunner or ContainerRunner or None
create_sandbox_runner()
# May be None if neither Docker nor wasmtime is available
# Just verify it doesn't crash
def test_factory_with_wasm_config(self):
class FakeConfig:
runtime = "wasm"
wasm_fuel_limit = 100_000
wasm_memory_limit_mb = 64
timeout = 10
image = "test"
runner = create_sandbox_runner(FakeConfig())
if WasmRunner.available():
assert isinstance(runner, WasmRunner)