From 1ad6f068f5e89923adc18cdd4bd36fd41121aa01 Mon Sep 17 00:00:00 2001 From: Luke Imhoff Date: Fri, 31 Aug 2018 16:31:08 -0500 Subject: [PATCH 1/2] Failing regression test for #638 --- apps/ethereum_jsonrpc/test/ethereum_jsonrpc/receipt_test.exs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/receipt_test.exs b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/receipt_test.exs index 60e80282d5..b54b2ae984 100644 --- a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/receipt_test.exs +++ b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/receipt_test.exs @@ -43,5 +43,10 @@ defmodule EthereumJSONRPC.ReceiptTest do }) end end + + # Regression test for https://github.com/poanetwork/blockscout/issues/638 + test ~s|"status" => nil is treated the same as no status| do + assert Receipt.to_elixir(%{"status" => nil, "transactionHash" => "0x0"}) == %{"transactionHash" => "0x0"} + end end end From d42fbdb06e3a00aca3ddd89fa5ef665d24d86f68 Mon Sep 17 00:00:00 2001 From: Luke Imhoff Date: Fri, 31 Aug 2018 16:31:41 -0500 Subject: [PATCH 2/2] Treat "status" => nil the same as no status While Geth does not return a status for pre-Byzantium blocks, Parity returns `"status" => nil`, so treat `"status" => nil` as if `"status"` wasn't there. --- apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex index 69975bf08f..0649d5ad0c 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex @@ -266,6 +266,7 @@ defmodule EthereumJSONRPC.Receipt do defp elixir_reducer({:ok, {_, _}}, {:error, _reasons} = acc_error), do: acc_error defp elixir_reducer({:error, reason}, {:ok, _}), do: {:error, [reason]} defp elixir_reducer({:error, reason}, {:error, reasons}), do: {:error, [reason | reasons]} + defp elixir_reducer(:ignore, acc), do: acc defp ok!({:ok, elixir}, _receipt), do: elixir @@ -327,6 +328,8 @@ defmodule EthereumJSONRPC.Receipt do case status do "0x0" -> {:ok, {key, :error}} "0x1" -> {:ok, {key, :ok}} + # pre-Byzantium / Ethereum Classic on Parity + nil -> :ignore other -> {:error, {:unknown_value, %{key: key, value: other}}} end end