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

Function waitForQueuedUsageModelTotalTokens

test/usage_logging_test.go:71–97  ·  view source on GitHub ↗
(t *testing.T, wantProvider, wantModel string, wantTokens int64)

Source from the content-addressed store, hash-verified

69}
70
71func waitForQueuedUsageModelTotalTokens(t *testing.T, wantProvider, wantModel string, wantTokens int64) {
72 t.Helper()
73
74 deadline := time.Now().Add(2 * time.Second)
75 for time.Now().Before(deadline) {
76 items := redisqueue.PopOldest(10)
77 for _, item := range items {
78 got, ok := parseQueuedUsagePayload(t, item)
79 if !ok {
80 continue
81 }
82 if got.Provider != wantProvider || got.Model != wantModel {
83 continue
84 }
85 if got.Failed {
86 t.Fatalf("payload failed = true, want false")
87 }
88 if got.Tokens.TotalTokens != wantTokens {
89 t.Fatalf("payload total tokens = %d, want %d", got.Tokens.TotalTokens, wantTokens)
90 }
91 return
92 }
93 time.Sleep(10 * time.Millisecond)
94 }
95
96 t.Fatalf("timed out waiting for queued usage payload for provider=%q model=%q", wantProvider, wantModel)
97}
98
99type queuedUsagePayload struct {
100 Provider string `json:"provider"`

Calls 2

PopOldestFunction · 0.92
parseQueuedUsagePayloadFunction · 0.85

Tested by

no test coverage detected