Skip to content

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/)

Terminal window
cd core/
uv run pytest # All tests
uv run pytest tests/unit/ # Unit tests only
uv run pytest tests/integration/ # Integration tests
uv run pytest -v --tb=short # Verbose output
uv run pytest --cov=antimatter_core # With coverage

Key Test Areas

ModuleTests
auth.pyToken verification, Ed25519 handshake, timing-safe compare
router.pyMessage routing to correct adapter, unknown type handling
tunnel.pyCloudflare tunnel lifecycle, reconnect logic
pty.pyPTY session spawn, I/O forwarding, resize

Android Tests (android/)

Terminal window
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 jacocoTestReport

Key Test Areas

ModuleTests
:core:networkBridgeWebSocket auth flow, message deserialization
:core:dataRoom DAO queries, FTS search
:feature:chatChatViewModel state transitions, step rendering
:feature:terminalTerminalViewModel PTY lifecycle
:feature:connectQR parsing, connection state machine

iOS Tests (ios/)

Open the project in Xcode and use โŒ˜U to run all tests, or via CLI:

Terminal window
xcodebuild test \
-workspace ios/AntimatterApp.xcworkspace \
-scheme AntimatterApp \
-destination 'platform=iOS Simulator,name=iPhone 16'

Key Test Areas

ModuleTests
CryptoEd25519 verification, AES-GCM decrypt
WebSocketAuth challenge flow, message deserialization
TerminalPTY session lifecycle, SwiftTerm integration

Adapter Tests

AG Adapter (TypeScript)

Terminal window
cd adapters/ag/
npm test # Jest unit tests
npm run lint # Type-check only

AG2 Adapter (Python)

Terminal window
cd adapters/ag2/
uv run pytest

CC Adapter (Node.js)

Terminal window
cd adapters/cc/
npm test

Manual 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

Saif Mukhtar

Saif Mukhtar

Creator & Lead Developer of Antimatter ยท Android, iOS & Python engineer