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

Function waitForSinglePayload

internal/redisqueue/plugin_test.go:249–270  ·  view source on GitHub ↗
(t *testing.T, timeout time.Duration)

Source from the content-addressed store, hash-verified

247}
248
249func waitForSinglePayload(t *testing.T, timeout time.Duration) map[string]json.RawMessage {
250 t.Helper()
251
252 deadline := time.Now().Add(timeout)
253 for time.Now().Before(deadline) {
254 items := PopOldest(10)
255 if len(items) == 0 {
256 time.Sleep(10 * time.Millisecond)
257 continue
258 }
259 if len(items) != 1 {
260 t.Fatalf("PopOldest() items = %d, want 1", len(items))
261 }
262 var payload map[string]json.RawMessage
263 if err := json.Unmarshal(items[0], &payload); err != nil {
264 t.Fatalf("unmarshal payload: %v", err)
265 }
266 return payload
267 }
268 t.Fatalf("timeout waiting for queued payload")
269 return nil
270}
271
272func requireStringField(t *testing.T, payload map[string]json.RawMessage, key, want string) {
273 t.Helper()

Calls 1

PopOldestFunction · 0.85

Tested by

no test coverage detected