(t *testing.T)
| 626 | } |
| 627 | |
| 628 | func TestNumericZeroRequestID(t *testing.T) { |
| 629 | s := makeTestServer(t) |
| 630 | |
| 631 | // Send request with numeric ID 0 (valid per JSON-RPC 2.0 spec) |
| 632 | request := newRequest(0, "health", nil).toJSON(t) |
| 633 | response := executeRequest(t, s, request) |
| 634 | |
| 635 | expected := map[string]interface{}{ |
| 636 | "jsonrpc": "2.0", |
| 637 | "id": float64(0), // JSON unmarshals numbers as float64 |
| 638 | } |
| 639 | if diff := compareJSON(expected, response); diff != "" { |
| 640 | t.Errorf("Response mismatch:\n%s", diff) |
| 641 | } |
| 642 | |
| 643 | // Verify it's a success response (has result, no error) |
| 644 | if response["result"] == nil { |
| 645 | t.Errorf("Expected result field, got nil") |
| 646 | } |
| 647 | if response["error"] != nil { |
| 648 | t.Errorf("Expected no error, got: %v", response["error"]) |
| 649 | } |
| 650 | } |
| 651 | |
| 652 | func TestParseErrorReturnsNullID(t *testing.T) { |
| 653 | s := makeTestServer(t) |
nothing calls this directly
no test coverage detected