rpc: fix receipt logs (#285)

* update GetTransactionReceipt and test

* change DecodeResultData err check back

* change doCall back

* change doCall back

* add logs

* remove prints
This commit is contained in:
noot 2020-05-14 16:55:33 -04:00 committed by GitHub
parent 542a25ff82
commit 51b68d7512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -708,6 +708,10 @@ func (e *PublicEthAPI) GetTransactionReceipt(hash common.Hash) (map[string]inter
status = 0 // transaction failed status = 0 // transaction failed
} }
if data.Logs == nil {
data.Logs = []*ethtypes.Log{}
}
receipt := map[string]interface{}{ receipt := map[string]interface{}{
// Consensus fields: These fields are defined by the Yellow Paper // Consensus fields: These fields are defined by the Yellow Paper
"status": status, "status": status,

View File

@ -276,6 +276,7 @@ func sendTestTransaction(t *testing.T) hexutil.Bytes {
param[0] = make(map[string]string) param[0] = make(map[string]string)
param[0]["from"] = "0x" + fmt.Sprintf("%x", from) param[0]["from"] = "0x" + fmt.Sprintf("%x", from)
param[0]["to"] = "0x1122334455667788990011223344556677889900" param[0]["to"] = "0x1122334455667788990011223344556677889900"
param[0]["value"] = "0x1"
rpcRes := call(t, "eth_sendTransaction", param) rpcRes := call(t, "eth_sendTransaction", param)
var hash hexutil.Bytes var hash hexutil.Bytes
@ -296,6 +297,7 @@ func TestEth_GetTransactionReceipt(t *testing.T) {
err := json.Unmarshal(rpcRes.Result, &receipt) err := json.Unmarshal(rpcRes.Result, &receipt)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, "0x1", receipt["status"].(string)) 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 // deployTestContract deploys a contract that emits an event in the constructor