From 51b68d7512cd4b243164aa4b2c84f66a901b45bb Mon Sep 17 00:00:00 2001 From: noot <36753753+noot@users.noreply.github.com> Date: Thu, 14 May 2020 16:55:33 -0400 Subject: [PATCH] rpc: fix receipt logs (#285) * update GetTransactionReceipt and test * change DecodeResultData err check back * change doCall back * change doCall back * add logs * remove prints --- rpc/eth_api.go | 4 ++++ tests/rpc_test.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/rpc/eth_api.go b/rpc/eth_api.go index 369fef966..ebb667613 100644 --- a/rpc/eth_api.go +++ b/rpc/eth_api.go @@ -708,6 +708,10 @@ func (e *PublicEthAPI) GetTransactionReceipt(hash common.Hash) (map[string]inter status = 0 // transaction failed } + if data.Logs == nil { + data.Logs = []*ethtypes.Log{} + } + receipt := map[string]interface{}{ // Consensus fields: These fields are defined by the Yellow Paper "status": status, diff --git a/tests/rpc_test.go b/tests/rpc_test.go index 9f9c94bd0..087e6dc78 100644 --- a/tests/rpc_test.go +++ b/tests/rpc_test.go @@ -276,6 +276,7 @@ func sendTestTransaction(t *testing.T) hexutil.Bytes { param[0] = make(map[string]string) param[0]["from"] = "0x" + fmt.Sprintf("%x", from) param[0]["to"] = "0x1122334455667788990011223344556677889900" + param[0]["value"] = "0x1" rpcRes := call(t, "eth_sendTransaction", param) var hash hexutil.Bytes @@ -296,6 +297,7 @@ func TestEth_GetTransactionReceipt(t *testing.T) { err := json.Unmarshal(rpcRes.Result, &receipt) require.NoError(t, err) require.Equal(t, "0x1", receipt["status"].(string)) + require.Equal(t, []interface{}{}, receipt["logs"].([]interface{})) } // deployTestContract deploys a contract that emits an event in the constructor