Merge pull request #977 from poanetwork/ams-fix-internal-transaction-listing

Fix InternalTransaction listing page by removing transaction fields.
pull/960/head
Andrew Cravenho 6 years ago committed by GitHub
commit e3555b8892
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      apps/block_scout_web/lib/block_scout_web/templates/internal_transaction/_tile.html.eex
  2. 25
      apps/block_scout_web/test/block_scout_web/controllers/address_internal_transaction_controller_test.exs
  3. 58
      apps/block_scout_web/test/block_scout_web/controllers/transaction_internal_transaction_controller_test.exs
  4. 33
      apps/block_scout_web/test/block_scout_web/features/viewing_addresses_test.exs
  5. 1
      apps/explorer/lib/explorer/chain.ex
  6. 4
      apps/explorer/lib/explorer/chain/internal_transaction.ex
  7. 22
      apps/explorer/test/explorer/chain_test.exs

@ -19,8 +19,8 @@
<div class="col-md-3 col-lg-2 d-flex flex-row flex-md-column flex-nowrap justify-content-start text-md-right mt-3 mt-md-0">
<span class="mr-2 mr-md-0 order-1">
<%= link(
gettext("Block #%{number}", number: to_string(@internal_transaction.transaction.block_number)),
to: block_path(BlockScoutWeb.Endpoint, :show, @internal_transaction.transaction.block)
gettext("Block #%{number}", number: to_string(@internal_transaction.block_number)),
to: block_path(BlockScoutWeb.Endpoint, :show, @internal_transaction.block_number)
) %>
</span>
<span class="mr-2 mr-md-0 order-2" data-from-now="<%= @internal_transaction.transaction.block.timestamp %>"></span>

@ -27,12 +27,25 @@ defmodule BlockScoutWeb.AddressInternalTransactionControllerTest do
transaction =
:transaction
|> insert()
|> with_block()
|> with_block(insert(:block, number: 1))
from_internal_transaction =
insert(:internal_transaction, transaction: transaction, from_address: address, index: 1)
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)
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)
conn = get(conn, path)
@ -145,7 +158,7 @@ defmodule BlockScoutWeb.AddressInternalTransactionControllerTest do
test "next_page_params exist if not on last page", %{conn: conn} do
address = insert(:address)
block = %Block{number: number} = insert(:block)
block = %Block{number: number} = insert(:block, number: 7000)
transaction =
%Transaction{index: transaction_index} =
@ -159,7 +172,9 @@ defmodule BlockScoutWeb.AddressInternalTransactionControllerTest do
:internal_transaction,
transaction: transaction,
from_address: address,
index: index
index: index,
block_number: transaction.block_number,
transaction_index: transaction.index
)
end)

@ -38,10 +38,22 @@ defmodule BlockScoutWeb.TransactionInternalTransactionControllerTest do
transaction =
:transaction
|> insert()
|> with_block()
|> with_block(insert(:block, number: 1))
expected_internal_transaction = insert(:internal_transaction, transaction: transaction, index: 0)
insert(:internal_transaction, transaction: transaction, index: 1)
expected_internal_transaction =
insert(:internal_transaction,
transaction: transaction,
index: 0,
block_number: transaction.block_number,
transaction_index: transaction.index
)
insert(:internal_transaction,
transaction: transaction,
index: 1,
transaction_index: transaction.index,
block_number: transaction.block_number
)
path = transaction_internal_transaction_path(BlockScoutWeb.Endpoint, :index, transaction.hash)
@ -71,11 +83,16 @@ defmodule BlockScoutWeb.TransactionInternalTransactionControllerTest do
:transaction
|> insert(to_address: nil)
|> with_contract_creation(contract_address)
|> with_block()
|> with_block(insert(:block, number: 7000))
internal_transaction =
:internal_transaction_create
|> insert(transaction: transaction, index: 0)
|> insert(
transaction: transaction,
index: 0,
block_number: transaction.block_number,
transaction_index: transaction.index
)
|> with_contract_creation(contract_address)
conn =
@ -95,13 +112,26 @@ defmodule BlockScoutWeb.TransactionInternalTransactionControllerTest do
transaction =
:transaction
|> insert()
|> with_block()
|> with_block(insert(:block, number: 7000))
%InternalTransaction{index: index} = insert(:internal_transaction, transaction: transaction, index: 0)
%InternalTransaction{index: index} =
insert(:internal_transaction,
transaction: transaction,
index: 0,
block_number: transaction.block_number,
transaction_index: transaction.index
)
second_page_indexes =
1..50
|> Enum.map(fn index -> insert(:internal_transaction, transaction: transaction, index: index) end)
|> Enum.map(fn index ->
insert(:internal_transaction,
transaction: transaction,
index: index,
block_number: transaction.block_number,
transaction_index: transaction.index
)
end)
|> Enum.map(& &1.index)
conn =
@ -117,7 +147,7 @@ defmodule BlockScoutWeb.TransactionInternalTransactionControllerTest do
end
test "next_page_params exist if not on last page", %{conn: conn} do
block = %Block{number: number} = insert(:block)
block = %Block{number: number} = insert(:block, number: 7000)
transaction =
%Transaction{index: transaction_index} =
@ -130,7 +160,9 @@ defmodule BlockScoutWeb.TransactionInternalTransactionControllerTest do
insert(
:internal_transaction,
transaction: transaction,
index: index
index: index,
block_number: transaction.block_number,
transaction_index: transaction.index
)
end)
@ -144,14 +176,16 @@ defmodule BlockScoutWeb.TransactionInternalTransactionControllerTest do
transaction =
:transaction
|> insert()
|> with_block()
|> with_block(insert(:block, number: 7000))
1..2
|> Enum.map(fn index ->
insert(
:internal_transaction,
transaction: transaction,
index: index
index: index,
block_number: transaction.block_number,
transaction_index: transaction.index
)
end)

@ -4,7 +4,7 @@ defmodule BlockScoutWeb.ViewingAddressesTest do
alias BlockScoutWeb.{AddressPage, AddressView, Notifier}
setup do
block = insert(:block)
block = insert(:block, number: 42)
lincoln = insert(:address, fetched_coin_balance: 5)
taft = insert(:address, fetched_coin_balance: 5)
@ -225,9 +225,22 @@ defmodule BlockScoutWeb.ViewingAddressesTest do
transaction = transactions.from_lincoln
internal_transaction_lincoln_to_address =
insert(:internal_transaction, transaction: transaction, to_address: address, index: 1)
insert(:internal_transaction,
transaction: transaction,
to_address: address,
index: 1,
block_number: 7000,
transaction_index: 1
)
insert(:internal_transaction,
transaction: transaction,
from_address: address,
index: 2,
block_number: 8000,
transaction_index: 2
)
insert(:internal_transaction, transaction: transaction, from_address: address, index: 2)
{:ok, %{internal_transaction_lincoln_to_address: internal_transaction_lincoln_to_address}}
end
@ -270,7 +283,7 @@ defmodule BlockScoutWeb.ViewingAddressesTest do
transaction =
:transaction
|> insert(from_address: addresses.lincoln)
|> with_block()
|> with_block(insert(:block, number: 7000))
session
|> AddressPage.visit_page(addresses.lincoln)
@ -278,7 +291,13 @@ defmodule BlockScoutWeb.ViewingAddressesTest do
|> assert_has(AddressPage.internal_transactions(count: 2))
internal_transaction =
insert(:internal_transaction, transaction: transaction, index: 2, from_address: addresses.lincoln)
insert(:internal_transaction,
transaction: transaction,
index: 2,
from_address: addresses.lincoln,
block_number: transaction.block_number,
transaction_index: transaction.index
)
Notifier.handle_event({:chain_event, :internal_transactions, :realtime, [internal_transaction]})
@ -307,7 +326,9 @@ defmodule BlockScoutWeb.ViewingAddressesTest do
|> insert(
transaction: from_lincoln,
from_address: lincoln,
index: 1
index: 1,
block_number: from_lincoln.block_number,
transaction_index: from_lincoln.index
)
|> with_contract_creation(contract_address)

@ -124,6 +124,7 @@ defmodule Explorer.Chain do
InternalTransaction
|> InternalTransaction.where_address_fields_match(hash, direction)
|> InternalTransaction.where_is_different_from_parent_transaction()
|> InternalTransaction.where_block_number_is_not_null()
|> page_internal_transaction(paging_options)
|> limit(^paging_options.page_size)
|> order_by(

@ -476,4 +476,8 @@ defmodule Explorer.Chain.InternalTransaction do
(it.type == ^:call and it.index > 0) or it.type != ^:call
)
end
def where_block_number_is_not_null(query) do
where(query, [t], not is_nil(t.block_number))
end
end

@ -1262,7 +1262,13 @@ defmodule Explorer.ChainTest do
describe "address_to_internal_transactions/1" do
test "with single transaction containing two internal transactions" do
address = insert(:address)
transaction = insert(:transaction)
block = insert(:block, number: 2000)
transaction =
:transaction
|> insert()
|> with_block(block)
%InternalTransaction{id: first_id} =
insert(:internal_transaction,
@ -1293,7 +1299,12 @@ defmodule Explorer.ChainTest do
test "loads associations in necessity_by_association" do
address = insert(:address)
transaction = insert(:transaction, to_address: address)
block = insert(:block, number: 2000)
transaction =
:transaction
|> insert()
|> with_block(block)
insert(:internal_transaction,
transaction: transaction,
@ -1341,7 +1352,12 @@ defmodule Explorer.ChainTest do
test "returns results in reverse chronological order by block number, transaction index, internal transaction index" do
address = insert(:address)
pending_transaction = insert(:transaction)
block = insert(:block, number: 7000)
pending_transaction =
:transaction
|> insert()
|> with_block(block)
%InternalTransaction{id: first_pending} =
insert(

Loading…
Cancel
Save