Mark to_address_hash as optional association on block->transactions page

It was previously incorrectly filtering out contract creation
transactions with no to_address_hash.

Co-authored-by: Stamates <stamates@hotmail.com>
pull/246/head
Tim Mecklem 7 years ago
parent 4526874a8c
commit d20af3d837
  1. 2
      apps/explorer_web/lib/explorer_web/controllers/block_transaction_controller.ex
  2. 20
      apps/explorer_web/test/explorer_web/controllers/block_transaction_controller_test.exs

@ -15,7 +15,7 @@ defmodule ExplorerWeb.BlockTransactionController do
necessity_by_association: %{
block: :required,
from_address: :required,
to_address: :required
to_address: :optional
},
pagination: params
)

@ -19,14 +19,13 @@ defmodule ExplorerWeb.BlockTransactionControllerTest do
test "returns transactions for the block", %{conn: conn} do
block = insert(:block)
:transaction
|> insert()
|> with_block(block)
:transaction |> insert() |> with_block(block)
:transaction |> insert(to_address_hash: nil) |> with_block(block)
conn = get(conn, block_transaction_path(ExplorerWeb.Endpoint, :index, :en, block.number))
assert html_response(conn, 200)
assert 1 == Enum.count(conn.assigns.page)
assert 2 == Enum.count(conn.assigns.page)
end
test "does not return unrelated transactions", %{conn: conn} do
@ -48,18 +47,5 @@ defmodule ExplorerWeb.BlockTransactionControllerTest do
assert html_response(conn, 200)
assert Enum.empty?(conn.assigns.page)
end
test "does not return related transactions without a to address", %{conn: conn} do
block = insert(:block)
:transaction
|> insert(to_address_hash: nil)
|> with_block(block)
conn = get(conn, block_transaction_path(ExplorerWeb.Endpoint, :index, :en, block))
assert html_response(conn, 200)
assert Enum.empty?(conn.assigns.page)
end
end
end

Loading…
Cancel
Save