Merge pull request #471 from nspcc-dev/rpc-minor-fixes

Minor RPC fixes
This commit is contained in:
Vsevolod 2019-11-02 22:13:17 +03:00 committed by GitHub
commit f48b19a305
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -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()
@ -157,7 +157,7 @@ Methods:
results = wrappers.NewBlock(block, s.chain)
case "getblockcount":
getblockcountCalled.Inc()
results = s.chain.BlockHeight()
results = s.chain.BlockHeight() + 1
case "getblockhash":
getblockHashCalled.Inc()

View file

@ -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) {
@ -51,7 +51,7 @@ func TestRPC(t *testing.T) {
var res IntResultResponse
err := json.Unmarshal(bytes.TrimSpace(body), &res)
assert.NoErrorf(t, err, "could not parse response: %s", body)
assert.Equal(t, chain.BlockHeight(), uint32(res.Result))
assert.Equal(t, chain.BlockHeight()+1, uint32(res.Result))
})
t.Run("getblockhash", func(t *testing.T) {