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

Function testSetup

sdk/api/handlers/injection_poison_test.go:25–35  ·  view source on GitHub ↗

--------------------------------------------------------------------------- E2E tests for the CompletePoisonCycle fix. Bug: CompletePoisonCycle was called on EVERY response, including intermediate responses that contained tool/function calls. The first call cleared poisonTaskID, so the final text r

(t *testing.T, format string, taskID uint32)

Source from the content-addressed store, hash-verified

23// testSetup swaps in a fresh session manager and creates a session with an
24// active poison cycle. Returns cleanup func, session ID, and the manager.
25func testSetup(t *testing.T, format string, taskID uint32) (cleanup func(), sessionID string, mgr *sessions.Manager) {
26 t.Helper()
27 mgr = sessions.NewManager(10 * time.Minute)
28 old := sessions.SwapGlobal(mgr)
29 cleanup = func() { sessions.SwapGlobal(old) }
30
31 sess := mgr.Touch("test-key", "test-agent/1.0", format, "test-session-poison")
32 sessionID = sess.ID
33 mgr.SetPoisonActive(sessionID, true, taskID)
34 return
35}
36
37// ginCtx builds a minimal gin.Context with the sessionID stored.
38func ginCtx(sessionID string) *gin.Context {

Calls 4

NewManagerFunction · 0.92
SwapGlobalFunction · 0.92
TouchMethod · 0.80
SetPoisonActiveMethod · 0.80

Tested by

no test coverage detected