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{})
| 406 | // assertJSONRPC20Success checks that a response is a successful JSON-RPC 2.0 response |
| 407 | // and returns the result data for further assertions |
| 408 | func 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 |
| 427 | func assertJSONRPC20Error(t *testing.T, response map[string]interface{}, expectedID interface{}, expectedCode float64) map[string]interface{} { |
nothing calls this directly
no test coverage detected