(t *testing.T)
| 602 | } |
| 603 | |
| 604 | func TestNumericRequestID(t *testing.T) { |
| 605 | s := makeTestServer(t) |
| 606 | |
| 607 | // Send request with numeric ID (JSON-RPC 2.0 compliant) |
| 608 | request := newRequest(42, "health", nil).toJSON(t) |
| 609 | response := executeRequest(t, s, request) |
| 610 | |
| 611 | expected := map[string]interface{}{ |
| 612 | "jsonrpc": "2.0", |
| 613 | "id": float64(42), // JSON unmarshals numbers as float64 |
| 614 | } |
| 615 | if diff := compareJSON(expected, response); diff != "" { |
| 616 | t.Errorf("Response mismatch:\n%s", diff) |
| 617 | } |
| 618 | |
| 619 | // Verify it's a success response (has result, no error) |
| 620 | if response["result"] == nil { |
| 621 | t.Errorf("Expected result field, got nil") |
| 622 | } |
| 623 | if response["error"] != nil { |
| 624 | t.Errorf("Expected no error, got: %v", response["error"]) |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | func TestNumericZeroRequestID(t *testing.T) { |
| 629 | s := makeTestServer(t) |
nothing calls this directly
no test coverage detected