mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 09:42:22 +00:00
rpc: add one to the block height for the getblockcount response
There is a difference in interpretation of what a block count is. neo-go nodes currently respond to this request with the latest block number which is the same number that neoscan.io shows. However, C# nodes deliberately do add one to this number when answering to the getblockcount request to account for the genesis block number 0. This patch makes us consistent with C# nodes wrt to getblockcount behaviour.
This commit is contained in:
parent
70e4529848
commit
de2eeb4671
2 changed files with 2 additions and 2 deletions
|
@ -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()
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue