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/pending_transaction_control...

59 lines
2.7 KiB

defmodule ExplorerWeb.PendingTransactionControllerTest do
use ExplorerWeb.ConnCase
import ExplorerWeb.Router.Helpers, only: [pending_transaction_path: 3]
describe "GET index/2" do
test "returns no transactions that have a receipt", %{conn: conn} do
transaction = insert(:transaction)
block = insert(:block)
address = insert(:address)
insert(:transaction_receipt, transaction: transaction)
insert(:block_transaction, transaction: transaction, block: block)
insert(:to_address, transaction: transaction, address: address)
insert(:from_address, transaction: transaction, address: address)
conn = get(conn, pending_transaction_path(ExplorerWeb.Endpoint, :index, :en))
assert conn.assigns.transactions.entries == []
end
test "does not count transactions that have a receipt", %{conn: conn} do
transaction = insert(:transaction)
block = insert(:block)
address = insert(:address)
insert(:transaction_receipt, transaction: transaction)
insert(:block_transaction, transaction: transaction, block: block)
insert(:to_address, transaction: transaction, address: address)
insert(:from_address, transaction: transaction, address: address)
conn = get(conn, pending_transaction_path(ExplorerWeb.Endpoint, :index, :en))
assert conn.assigns.transactions.total_entries === 0
end
test "returns pending transactions", %{conn: conn} do
address = insert(:address)
transaction = insert(:transaction)
insert(:to_address, transaction: transaction, address: address)
insert(:from_address, transaction: transaction, address: address)
conn = get(conn, pending_transaction_path(ExplorerWeb.Endpoint, :index, :en))
assert List.first(conn.assigns.transactions.entries).id == transaction.id
end
test "returns a count of pending transactions", %{conn: conn} do
address = insert(:address)
transaction = insert(:transaction)
insert(:to_address, transaction: transaction, address: address)
insert(:from_address, transaction: transaction, address: address)
conn = get(conn, pending_transaction_path(ExplorerWeb.Endpoint, :index, :en))
assert conn.assigns.transactions.total_entries === 1
end
test "paginates transactions using the last seen transaction", %{conn: conn} do
address = insert(:address)
transaction = insert(:transaction)
insert(:to_address, transaction: transaction, address: address)
insert(:from_address, transaction: transaction, address: address)
conn = get(conn, pending_transaction_path(ExplorerWeb.Endpoint, :index, :en), last_seen: transaction.id)
assert conn.assigns.transactions.entries == []
end
end
end