From 70e45298486756401a3792ab4e2904700486f023 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 1 Nov 2019 16:36:32 +0300 Subject: [PATCH] rpc: add `0x` prefix to the getbestblockhash answer For consistency with C# nodes that do add it to their answers. --- pkg/rpc/server.go | 2 +- pkg/rpc/server_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/rpc/server.go b/pkg/rpc/server.go index a767663f5..93d767f1a 100644 --- a/pkg/rpc/server.go +++ b/pkg/rpc/server.go @@ -117,7 +117,7 @@ Methods: switch req.Method { case "getbestblockhash": getbestblockhashCalled.Inc() - results = s.chain.CurrentBlockHash().ReverseString() + results = "0x" + s.chain.CurrentBlockHash().ReverseString() case "getblock": getbestblockCalled.Inc() diff --git a/pkg/rpc/server_test.go b/pkg/rpc/server_test.go index 3d6c139e1..1f6424d72 100644 --- a/pkg/rpc/server_test.go +++ b/pkg/rpc/server_test.go @@ -28,7 +28,7 @@ func TestRPC(t *testing.T) { var res StringResultResponse err := json.Unmarshal(bytes.TrimSpace(body), &res) assert.NoErrorf(t, err, "could not parse response: %s", body) - assert.Equal(t, chain.CurrentBlockHash().ReverseString(), res.Result) + assert.Equal(t, "0x"+chain.CurrentBlockHash().ReverseString(), res.Result) }) t.Run("getblock", func(t *testing.T) {