Comment test for disabled functionality

pull/11066/head
Viktor Baranov 3 weeks ago
parent daa13a8ca7
commit ab7eddd3d0
  1. 175
      apps/block_scout_web/test/block_scout_web/controllers/api/v2/internal_transaction_controller_test.exs

@ -3,91 +3,92 @@ defmodule BlockScoutWeb.API.V2.InternalTransactionControllerTest do
alias Explorer.Chain.{Address, InternalTransaction} alias Explorer.Chain.{Address, InternalTransaction}
describe "/internal-transactions" do # todo: enable when /internal-transactions API endpoint will be enabled
test "empty list", %{conn: conn} do # describe "/internal-transactions" do
request = get(conn, "/api/v2/internal-transactions") # test "empty list", %{conn: conn} do
# request = get(conn, "/api/v2/internal-transactions")
assert response = json_response(request, 200)
assert response["items"] == [] # assert response = json_response(request, 200)
assert response["next_page_params"] == nil # assert response["items"] == []
end # assert response["next_page_params"] == nil
# end
test "non empty list", %{conn: conn} do
tx = # test "non empty list", %{conn: conn} do
:transaction # tx =
|> insert() # :transaction
|> with_block() # |> insert()
# |> with_block()
insert(:internal_transaction,
transaction: tx, # insert(:internal_transaction,
block_hash: tx.block_hash, # transaction: tx,
index: 0, # block_hash: tx.block_hash,
block_index: 0 # index: 0,
) # block_index: 0
# )
request = get(conn, "/api/v2/internal-transactions")
# request = get(conn, "/api/v2/internal-transactions")
assert response = json_response(request, 200)
assert Enum.count(response["items"]) == 1 # assert response = json_response(request, 200)
assert response["next_page_params"] == nil # assert Enum.count(response["items"]) == 1
end # assert response["next_page_params"] == nil
# end
test "internal transactions with next_page_params", %{conn: conn} do
transaction = insert(:transaction) |> with_block() # test "internal transactions with next_page_params", %{conn: conn} do
# transaction = insert(:transaction) |> with_block()
internal_transaction =
insert(:internal_transaction, # internal_transaction =
transaction: transaction, # insert(:internal_transaction,
transaction_index: 0, # transaction: transaction,
block_number: transaction.block_number, # transaction_index: 0,
block_hash: transaction.block_hash, # block_number: transaction.block_number,
index: 0, # block_hash: transaction.block_hash,
block_index: 0 # index: 0,
) # block_index: 0
# )
transaction_2 = insert(:transaction) |> with_block()
# transaction_2 = insert(:transaction) |> with_block()
internal_transactions =
for i <- 0..49 do # internal_transactions =
insert(:internal_transaction, # for i <- 0..49 do
transaction: transaction_2, # insert(:internal_transaction,
transaction_index: 0, # transaction: transaction_2,
block_number: transaction_2.block_number, # transaction_index: 0,
block_hash: transaction_2.block_hash, # block_number: transaction_2.block_number,
index: i, # block_hash: transaction_2.block_hash,
block_index: i # index: i,
) # block_index: i
end # )
# end
internal_transactions = [internal_transaction | internal_transactions]
# internal_transactions = [internal_transaction | internal_transactions]
request = get(conn, "/api/v2/internal-transactions")
assert response = json_response(request, 200) # request = get(conn, "/api/v2/internal-transactions")
# assert response = json_response(request, 200)
request_2nd_page = get(conn, "/api/v2/internal-transactions", response["next_page_params"])
assert response_2nd_page = json_response(request_2nd_page, 200) # request_2nd_page = get(conn, "/api/v2/internal-transactions", response["next_page_params"])
# assert response_2nd_page = json_response(request_2nd_page, 200)
check_paginated_response(response, response_2nd_page, internal_transactions)
end # check_paginated_response(response, response_2nd_page, internal_transactions)
end # end
# end
defp compare_item(%InternalTransaction{} = internal_transaction, json) do
assert Address.checksum(internal_transaction.from_address_hash) == json["from"]["hash"] # defp compare_item(%InternalTransaction{} = internal_transaction, json) do
assert Address.checksum(internal_transaction.to_address_hash) == json["to"]["hash"] # assert Address.checksum(internal_transaction.from_address_hash) == json["from"]["hash"]
assert to_string(internal_transaction.transaction_hash) == json["transaction_hash"] # assert Address.checksum(internal_transaction.to_address_hash) == json["to"]["hash"]
assert internal_transaction.block_number == json["block_number"] # assert to_string(internal_transaction.transaction_hash) == json["transaction_hash"]
assert internal_transaction.block_index == json["block_index"] # assert internal_transaction.block_number == json["block_number"]
end # assert internal_transaction.block_index == json["block_index"]
# end
defp check_paginated_response(first_page_resp, second_page_resp, internal_transactions) do
assert Enum.count(first_page_resp["items"]) == 50 # defp check_paginated_response(first_page_resp, second_page_resp, internal_transactions) do
assert first_page_resp["next_page_params"] != nil # assert Enum.count(first_page_resp["items"]) == 50
compare_item(Enum.at(internal_transactions, 50), Enum.at(first_page_resp["items"], 0)) # assert first_page_resp["next_page_params"] != nil
# compare_item(Enum.at(internal_transactions, 50), Enum.at(first_page_resp["items"], 0))
compare_item(Enum.at(internal_transactions, 1), Enum.at(first_page_resp["items"], 49))
# compare_item(Enum.at(internal_transactions, 1), Enum.at(first_page_resp["items"], 49))
assert Enum.count(second_page_resp["items"]) == 1
assert second_page_resp["next_page_params"] == nil # assert Enum.count(second_page_resp["items"]) == 1
compare_item(Enum.at(internal_transactions, 0), Enum.at(second_page_resp["items"], 0)) # assert second_page_resp["next_page_params"] == nil
end # compare_item(Enum.at(internal_transactions, 0), Enum.at(second_page_resp["items"], 0))
# end
end end

Loading…
Cancel
Save