From c542f4a9fcdd350712decc175a63a071b467aed4 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 14 Jun 2019 11:35:23 +0300 Subject: [PATCH 1/2] handle correctly empty transactions --- apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/block.ex | 2 ++ apps/ethereum_jsonrpc/test/ethereum_jsonrpc/block_test.exs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/block.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/block.ex index 6be34eeee1..1c52a6e6c9 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/block.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/block.ex @@ -319,6 +319,8 @@ defmodule EthereumJSONRPC.Block do @spec elixir_to_transactions(elixir) :: Transactions.elixir() def elixir_to_transactions(%{"transactions" => transactions}), do: transactions + def elixir_to_transactions(_), do: [] + @doc """ Get `t:EthereumJSONRPC.Uncles.elixir/0` from `t:elixir/0`. diff --git a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/block_test.exs b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/block_test.exs index 1cf16c6f47..23e1e442c5 100644 --- a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/block_test.exs +++ b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/block_test.exs @@ -56,4 +56,10 @@ defmodule EthereumJSONRPC.BlockTest do } end end + + describe "elixir_to_transactions/1" do + test "converts to empty list if there is not transaction key" do + assert Block.elixir_to_transactions(%{}) == [] + end + end end From fd6a99a344b73e4f812fce59805418f5ec968e58 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 14 Jun 2019 11:42:40 +0300 Subject: [PATCH 2/2] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f77cb5439a..273f89b0f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - [#2119](https://github.com/poanetwork/blockscout/pull/2119) - fix map logging - [#2130](https://github.com/poanetwork/blockscout/pull/2130) - fix navigation - [#2149](https://github.com/poanetwork/blockscout/pull/2149) - remove pending transaction count +- [#2173](https://github.com/poanetwork/blockscout/pull/2173) - handle correctly empty transactions ### Chore - [#2127](https://github.com/poanetwork/blockscout/pull/2127) - use previouse chromedriver version