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/forms/transaction_form_test.exs

25 lines
933 B

defmodule Explorer.TransactionFormTest do
use Explorer.DataCase
alias Explorer.TransactionForm
describe "build/1" do
test "that it has a block number" do
block = insert(:block, number: 622)
transaction = insert(:transaction, block: block)
assert TransactionForm.build(transaction).block_number == 622
end
test "that it returns the block's age" do
block = insert(:block, timestamp: Timex.now |> Timex.shift(hours: -2))
transaction = insert(:transaction, block: block)
assert TransactionForm.build(transaction).age == "2 hours ago"
end
test "formats the block's timestamp" do
date = "Feb-02-2010 10:48:56 AM Etc/UTC"
block = insert(:block, timestamp: Timex.parse!(date, "%b-%d-%Y %H:%M:%S %p %Z", :strftime))
transaction = insert(:transaction, block: block)
assert TransactionForm.build(transaction).formatted_timestamp == date
end
end
end