MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / simulateInbound

Function simulateInbound

internal/relay/flow_test.go:32–42  ·  view source on GitHub ↗

simulateInbound reproduces the relay's decisions for a single inbound message: it parses threading info, gates the X-E2A-Conversation-ID header on the envelope domain, and picks the display sender the way deliverToAgent does. lookup can be nil to simulate "no prior thread in DB".

(t *testing.T, raw []byte, envelopeFrom string, lookup func(ctx context.Context, ids []string) (string, error))

Source from the content-addressed store, hash-verified

30// on the envelope domain, and picks the display sender the way deliverToAgent
31// does. lookup can be nil to simulate "no prior thread in DB".
32func simulateInbound(t *testing.T, raw []byte, envelopeFrom string, lookup func(ctx context.Context, ids []string) (string, error)) (sender, conversationID string) {
33 t.Helper()
34 info := extractThreadInfo(raw)
35 trusted := strings.EqualFold(extractDomain(envelopeFrom), relayFromDomain)
36 sender = info.From
37 if len(info.ReplyTo) > 0 {
38 sender = info.ReplyTo[0]
39 }
40 conversationID = resolveConversationID(context.Background(), info, trusted, lookup)
41 return sender, conversationID
42}
43
44// composeAgentOutbound mirrors what sender.go does for a real agent send or
45// reply: "{display} via e2a" <agent@send.e2a.dev> for From, agent's real

Calls 3

extractThreadInfoFunction · 0.85
resolveConversationIDFunction · 0.85
extractDomainFunction · 0.70

Tested by

no test coverage detected