Skip to content

P2: Add end-to-end integration test for relay message flow #208

@vrknetha

Description

@vrknetha

Summary

There are unit tests for individual components (connector client, proxy auth, inbound inbox, relay sessions, pairing) but no test that exercises the full message flow end-to-end:

transform → connector /v1/outbound → WebSocket → proxy → relay session 
  → WebSocket push → inbound connector → OpenClaw hook delivery

For a security-critical messaging system, this is a meaningful gap.

What's Missing

  1. Full relay flow test: Message sent by Agent A arrives at Agent B's OpenClaw hook with correct identity headers
  2. Pairing flow test: Two agents pair via ticket, then can exchange messages
  3. Dead letter + replay test: Message fails delivery, dead-letters, replays, eventually delivers
  4. Trust enforcement test: Unpaired agent cannot send to another agent
  5. Conversation ordering test: Messages with same conversationId are delivered in order

Proposed Approach

Test Infrastructure

  • Local registry (mock or real, on localhost)
  • Local proxy (Miniflare or direct Hono app)
  • Two connector instances (Agent A, Agent B)
  • Two mock OpenClaw hook servers (simple HTTP servers that collect received payloads)

Test Scenarios

Scenario 1: Happy path relay

  1. Bootstrap Agent A and Agent B with identities
  2. Pair A ↔ B
  3. A sends message to B via connector
  4. Assert: B's OpenClaw hook receives the message with correct headers

Scenario 2: Auth rejection

  1. Agent C (unpaired with B) tries to send to B
  2. Assert: proxy returns 403 PROXY_AUTH_FORBIDDEN

Scenario 3: Dead letter and replay

  1. B's OpenClaw hook returns 500
  2. A sends a message
  3. Assert: message ends up in B's dead letter
  4. Fix B's hook (return 200)
  5. Trigger replay
  6. Assert: message delivered successfully

Scenario 4: Delivery receipt

  1. A sends message with replyTo callback URL
  2. B's connector delivers successfully
  3. Assert: A receives processed_by_openclaw receipt at callback URL

Files to Create

  • tests/e2e/relay-flow.test.ts — main integration test file
  • tests/e2e/helpers/mock-openclaw-hook.ts — simple HTTP server that collects payloads
  • tests/e2e/helpers/test-bootstrap.ts — helper to create agent identities and pair them
  • tests/e2e/helpers/local-proxy.ts — Hono app with proxy routes for testing

Acceptance Criteria

  • At least scenarios 1-3 implemented and passing
  • Tests run in CI without external dependencies (no real CF Workers)
  • Test execution time < 30s
  • Tests are deterministic (no timing-dependent flakes)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Quality improvementconnectorConnector packageenhancementNew feature or requestproxyProxy / CF Worker

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions