|
|
@ -69,6 +69,90 @@ defmodule BlockScoutWeb.AddressInternalTransactionControllerTest do |
|
|
|
end) |
|
|
|
end) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test "returns internal transactions coming from the address", %{conn: conn} do |
|
|
|
|
|
|
|
address = insert(:address) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
transaction = |
|
|
|
|
|
|
|
:transaction |
|
|
|
|
|
|
|
|> insert() |
|
|
|
|
|
|
|
|> with_block(insert(:block, number: 1)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from_internal_transaction = |
|
|
|
|
|
|
|
insert(:internal_transaction, |
|
|
|
|
|
|
|
transaction: transaction, |
|
|
|
|
|
|
|
from_address: address, |
|
|
|
|
|
|
|
index: 1, |
|
|
|
|
|
|
|
block_number: transaction.block_number, |
|
|
|
|
|
|
|
transaction_index: transaction.index |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
to_internal_transaction = |
|
|
|
|
|
|
|
insert(:internal_transaction, |
|
|
|
|
|
|
|
transaction: transaction, |
|
|
|
|
|
|
|
to_address: address, |
|
|
|
|
|
|
|
index: 2, |
|
|
|
|
|
|
|
block_number: transaction.block_number, |
|
|
|
|
|
|
|
transaction_index: transaction.index |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
path = address_internal_transaction_path(conn, :index, address, %{"filter" => "from", "type" => "JSON"}) |
|
|
|
|
|
|
|
conn = get(conn, path) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal_transaction_tiles = json_response(conn, 200)["items"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert Enum.any?(internal_transaction_tiles, fn tile -> |
|
|
|
|
|
|
|
String.contains?(tile, to_string(from_internal_transaction.transaction_hash)) && |
|
|
|
|
|
|
|
String.contains?(tile, "data-internal-transaction-index=\"#{from_internal_transaction.index}\"") |
|
|
|
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
refute Enum.any?(internal_transaction_tiles, fn tile -> |
|
|
|
|
|
|
|
String.contains?(tile, to_string(to_internal_transaction.transaction_hash)) && |
|
|
|
|
|
|
|
String.contains?(tile, "data-internal-transaction-index=\"#{to_internal_transaction.index}\"") |
|
|
|
|
|
|
|
end) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test "returns internal transactions going to the address", %{conn: conn} do |
|
|
|
|
|
|
|
address = insert(:address) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
transaction = |
|
|
|
|
|
|
|
:transaction |
|
|
|
|
|
|
|
|> insert() |
|
|
|
|
|
|
|
|> with_block(insert(:block, number: 1)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from_internal_transaction = |
|
|
|
|
|
|
|
insert(:internal_transaction, |
|
|
|
|
|
|
|
transaction: transaction, |
|
|
|
|
|
|
|
from_address: address, |
|
|
|
|
|
|
|
index: 1, |
|
|
|
|
|
|
|
block_number: transaction.block_number, |
|
|
|
|
|
|
|
transaction_index: transaction.index |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
to_internal_transaction = |
|
|
|
|
|
|
|
insert(:internal_transaction, |
|
|
|
|
|
|
|
transaction: transaction, |
|
|
|
|
|
|
|
to_address: address, |
|
|
|
|
|
|
|
index: 2, |
|
|
|
|
|
|
|
block_number: transaction.block_number, |
|
|
|
|
|
|
|
transaction_index: transaction.index |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
path = address_internal_transaction_path(conn, :index, address, %{"filter" => "to", "type" => "JSON"}) |
|
|
|
|
|
|
|
conn = get(conn, path) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal_transaction_tiles = json_response(conn, 200)["items"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert Enum.any?(internal_transaction_tiles, fn tile -> |
|
|
|
|
|
|
|
String.contains?(tile, to_string(to_internal_transaction.transaction_hash)) && |
|
|
|
|
|
|
|
String.contains?(tile, "data-internal-transaction-index=\"#{to_internal_transaction.index}\"") |
|
|
|
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
refute Enum.any?(internal_transaction_tiles, fn tile -> |
|
|
|
|
|
|
|
String.contains?(tile, to_string(from_internal_transaction.transaction_hash)) && |
|
|
|
|
|
|
|
String.contains?(tile, "data-internal-transaction-index=\"#{from_internal_transaction.index}\"") |
|
|
|
|
|
|
|
end) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
test "returns next page of results based on last seen internal transaction", %{conn: conn} do |
|
|
|
test "returns next page of results based on last seen internal transaction", %{conn: conn} do |
|
|
|
address = insert(:address) |
|
|
|
address = insert(:address) |
|
|
|
|
|
|
|
|
|
|
|