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/receipt_test.exs

41 lines
1.4 KiB

defmodule Explorer.ReceiptTest do
use Explorer.DataCase
alias Explorer.Receipt
describe "changeset/2" do
test "accepts valid attributes" do
transaction = insert(:transaction)
params = params_for(:receipt, transaction: transaction)
changeset = Receipt.changeset(%Receipt{}, params)
assert changeset.valid?
end
test "rejects missing attributes" do
transaction = insert(:transaction)
params = params_for(:receipt, transaction: transaction, cumulative_gas_used: nil)
changeset = Receipt.changeset(%Receipt{}, params)
refute changeset.valid?
end
test "accepts logs" do
transaction = insert(:transaction)
address = insert(:address)
log_params = params_for(:log, address: address)
params = params_for(:receipt, transaction: transaction, logs: [log_params])
changeset = Receipt.changeset(%Receipt{}, params)
assert changeset.valid?
end
test "saves logs for the receipt" do
transaction = insert(:transaction)
address = insert(:address)
log_params = params_for(:log, address: address)
params = params_for(:receipt, transaction: transaction, logs: [log_params])
changeset = Receipt.changeset(%Receipt{}, params)
receipt = Repo.insert!(changeset) |> Repo.preload([logs: :address])
assert List.first(receipt.logs).address == address
end
end
end