Testing Guide
This guide covers the testing strategies across the Antimatter monorepo โ Gateway, adapters, and mobile apps.
Philosophy
Antimatter follows a pragmatic testing pyramid:
- Unit tests for business logic โ protocol parsing, message routing, crypto verification.
- Integration tests for WebSocket protocol flows โ auth handshake, message forwarding, PTY lifecycle.
- End-to-end tests for critical paths โ QR pairing, agent prompt round-trip.
Gateway Tests (core/)
cd core/uv run pytest # All testsuv run pytest tests/unit/ # Unit tests onlyuv run pytest tests/integration/ # Integration testsuv run pytest -v --tb=short # Verbose outputuv run pytest --cov=antimatter_core # With coverageKey Test Areas
| Module | Tests |
|---|---|
auth.py | Token verification, Ed25519 handshake, timing-safe compare |
router.py | Message routing to correct adapter, unknown type handling |
tunnel.py | Cloudflare tunnel lifecycle, reconnect logic |
pty.py | PTY session spawn, I/O forwarding, resize |
Android Tests (android/)
cd android/
# Unit tests (JVM, no device needed)./gradlew testDebugUnitTest
# Instrumented tests (requires connected device/emulator)./gradlew connectedDebugAndroidTest
# Single module tests./gradlew :core:network:testDebugUnitTest./gradlew :feature:terminal:testDebugUnitTest
# Coverage report./gradlew testDebugUnitTest jacocoTestReportKey Test Areas
| Module | Tests |
|---|---|
:core:network | BridgeWebSocket auth flow, message deserialization |
:core:data | Room DAO queries, FTS search |
:feature:chat | ChatViewModel state transitions, step rendering |
:feature:terminal | TerminalViewModel PTY lifecycle |
:feature:connect | QR parsing, connection state machine |
iOS Tests (ios/)
Open the project in Xcode and use โU to run all tests, or via CLI:
xcodebuild test \ -workspace ios/AntimatterApp.xcworkspace \ -scheme AntimatterApp \ -destination 'platform=iOS Simulator,name=iPhone 16'Key Test Areas
| Module | Tests |
|---|---|
Crypto | Ed25519 verification, AES-GCM decrypt |
WebSocket | Auth challenge flow, message deserialization |
Terminal | PTY session lifecycle, SwiftTerm integration |
Adapter Tests
AG Adapter (TypeScript)
cd adapters/ag/npm test # Jest unit testsnpm run lint # Type-check onlyAG2 Adapter (Python)
cd adapters/ag2/uv run pytestCC Adapter (Node.js)
cd adapters/cc/npm testManual Testing Checklist
Before submitting a PR that touches the auth flow or protocol, verify these scenarios manually:
- Fresh QR pairing completes successfully
- Re-pairing (scan new QR) correctly replaces the old session
- Invalid token produces close code
4001 - App reconnects cleanly after Gateway restart
- PTY terminal: start session, type commands, resize, close
- File browser loads workspace tree
- Prompt injection reaches active agent
- Push notification fires on agent task completion
- Biometric gate blocks connection until authenticated