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

Method execWSConnect

tests/contract/contract_test.go:421–444  ·  view source on GitHub ↗
(t *testing.T, s *step)

Source from the content-addressed store, hash-verified

419}
420
421func (r *runner) execWSConnect(t *testing.T, s *step) {
422 t.Helper()
423
424 path := r.resolve(s.Path)
425
426 // Extract agent email from WS path (e.g., /v1/agents/bot@ws.test.dev/ws)
427 agentEmail := extractEmailFromWSPath(path)
428 ag, err := r.env.store.GetAgentByEmail(context.Background(), agentEmail)
429 if err != nil {
430 t.Fatalf("step %s: get agent %s: %v", s.ID, agentEmail, err)
431 }
432 r.wsAgent = ag.ID
433
434 wsURL := "ws" + strings.TrimPrefix(r.env.baseURL, "http") + path
435 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
436 defer cancel()
437
438 conn, _, err := websocket.Dial(ctx, wsURL, wsDialOpts(r.env.apiKey))
439 if err != nil {
440 t.Fatalf("step %s: ws dial: %v", s.ID, err)
441 }
442 r.wsConn = conn
443 r.env.waitWSConnected(t, r.wsAgent)
444}
445
446// wsDialOpts authenticates the WS handshake with Authorization: Bearer (the
447// credential is never in the URL — header-only auth).

Callers 1

executeStepsMethod · 0.95

Calls 5

resolveMethod · 0.95
wsDialOptsFunction · 0.85
waitWSConnectedMethod · 0.80
extractEmailFromWSPathFunction · 0.70
GetAgentByEmailMethod · 0.65

Tested by

no test coverage detected