MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / setupTestBridge

Function setupTestBridge

internal/bridge/transfer_e2e_test.go:96–115  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Test helper: create a Bridge with mock stream and local Manager ---------------------------------------------------------------------------

(t *testing.T, mgr *sessions.Manager, userAgent string, tools []observedtools.ObservedTool)

Source from the content-addressed store, hash-verified

94// ---------------------------------------------------------------------------
95
96func setupTestBridge(t *testing.T, mgr *sessions.Manager, userAgent string, tools []observedtools.ObservedTool) (*Bridge, *mockSpiteStream, *sessions.Session) {
97 t.Helper()
98 stream := newMockSpiteStream()
99 ctx, cancel := context.WithCancel(context.Background())
100 t.Cleanup(cancel)
101 b := &Bridge{
102 listenerID: "test-listener",
103 pipelineID: "test-pipeline",
104 spiteStream: stream,
105 registry: buildDefaultRegistry(),
106 taskManager: NewTaskManager(),
107 ctx: ctx,
108 cancel: cancel,
109 }
110
111 sess := mgr.Touch("test-key", userAgent, "claude", "")
112 sess.RecordToolsDirect(tools)
113
114 return b, stream, sess
115}
116
117// simulateToolResult publishes a CommandResult to the manager after a short delay.
118func simulateToolResult(mgr *sessions.Manager, sessionID string, taskID uint32, output string, delay time.Duration) {

Calls 6

newMockSpiteStreamFunction · 0.85
buildDefaultRegistryFunction · 0.85
NewTaskManagerFunction · 0.85
TouchMethod · 0.80
RecordToolsDirectMethod · 0.80
CleanupMethod · 0.45

Tested by

no test coverage detected