rpc: return 0x0 as extra data in block instead of nil (#333)

* return 0x0 extra data instead of nil

* add fix for getBlock

* add tests
This commit is contained in:
noot 2020-06-17 12:14:21 -04:00 committed by GitHub
parent 7b164a5aa4
commit 94f6acc651
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -526,7 +526,7 @@ func formatBlock(
"miner": common.Address{},
"difficulty": nil,
"totalDifficulty": nil,
"extraData": nil,
"extraData": hexutil.Uint64(0),
"size": hexutil.Uint64(size),
"gasLimit": hexutil.Uint64(gasLimit), // Static gas limit
"gasUsed": (*hexutil.Big)(gasUsed),

View File

@ -634,11 +634,11 @@ func TestBlockBloom(t *testing.T) {
}
func TestBlockBloom_Hash(t *testing.T) {
t.Skip()
// TODO: get this to work
hash := deployTestContractWithFunction(t)
receipt := waitForReceipt(t, hash)
time.Sleep(time.Second * 3)
blockHash := receipt["blockHash"].(string)
param := []interface{}{blockHash, false}
@ -685,3 +685,13 @@ func TestEth_EstimateGas(t *testing.T) {
require.Equal(t, hexutil.Bytes{0xf7, 0xa6}, gas)
}
func TestEth_GetBlockByNumber(t *testing.T) {
param := []interface{}{"0x1", false}
rpcRes := call(t, "eth_getBlockByNumber", param)
block := make(map[string]interface{})
err := json.Unmarshal(rpcRes.Result, &block)
require.NoError(t, err)
require.Equal(t, "0x0", block["extraData"].(string))
}