handle correctly empty transactions

pull/2173/head
Ayrat Badykov 6 years ago
parent 951045356d
commit c542f4a9fc
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 2
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/block.ex
  2. 6
      apps/ethereum_jsonrpc/test/ethereum_jsonrpc/block_test.exs

@ -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`.

@ -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

Loading…
Cancel
Save