Blockchain explorer for Ethereum based network and a tool for inspecting and analyzing EVM based blockchains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
blockscout/test/explorer_web/controllers/transaction_controller_test...

29 lines
1.2 KiB

defmodule ExplorerWeb.TransactionControllerTest do
use ExplorerWeb.ConnCase
describe "GET index/2" do
test "returns all transactions", %{conn: conn} do
transaction_ids = insert_list(4, :transaction) |> list_with_block |> Enum.map(fn (transaction) -> transaction.id end)
conn = get(conn, "/en/transactions")
assert conn.assigns.transactions |> Enum.map(fn (transaction) -> transaction.id end) == transaction_ids
end
end
describe "GET show/3" do
test "when there is an associated block, it returns a transaction with block data", %{conn: conn} do
block = insert(:block, %{number: 777})
transaction = insert(:transaction, hash: "0x8") |> with_block(block) |> with_addresses
conn = get(conn, "/en/transactions/0x8")
assert conn.assigns.transaction.id == transaction.id
assert conn.assigns.transaction.block_number == block.number
end
test "returns a transaction without associated block data", %{conn: conn} do
transaction = insert(:transaction, hash: "0x8") |> with_addresses
conn = get(conn, "/en/transactions/0x8")
assert conn.assigns.transaction.id == transaction.id
assert conn.assigns.transaction.block_number == ""
end
end
end