MCPcopy Create free account
hub / github.com/asternic/wuzapi / assertJSONRPC20Success

Function assertJSONRPC20Success

stdio_test.go:408–424  ·  view source on GitHub ↗

assertJSONRPC20Success checks that a response is a successful JSON-RPC 2.0 response and returns the result data for further assertions

(t *testing.T, response map[string]interface{}, expectedID interface{})

Source from the content-addressed store, hash-verified

406// assertJSONRPC20Success checks that a response is a successful JSON-RPC 2.0 response
407// and returns the result data for further assertions
408func assertJSONRPC20Success(t *testing.T, response map[string]interface{}, expectedID interface{}) interface{} {
409 t.Helper()
410 expected := map[string]interface{}{
411 "jsonrpc": "2.0",
412 "id": expectedID,
413 }
414 if diff := compareJSON(expected, response); diff != "" {
415 t.Errorf("Response structure mismatch:\n%s", diff)
416 }
417 if response["error"] != nil {
418 t.Fatalf("Expected no error, got: %v", response["error"])
419 }
420 if response["result"] == nil {
421 t.Fatalf("Expected result field, got nil")
422 }
423 return response["result"]
424}
425
426// assertJSONRPC20Error checks that a response is an error JSON-RPC 2.0 response
427func assertJSONRPC20Error(t *testing.T, response map[string]interface{}, expectedID interface{}, expectedCode float64) map[string]interface{} {

Callers

nothing calls this directly

Calls 1

compareJSONFunction · 0.85

Tested by

no test coverage detected