Fixup test cases

pull/1040/head
svenski123 6 years ago
parent 20543a2ca0
commit ae9f4140ea
  1. 4
      apps/block_scout_web/test/block_scout_web/controllers/address_controller_test.exs
  2. 17
      apps/explorer/lib/explorer/chain.ex
  3. 12
      apps/explorer/test/explorer/chain_test.exs

@ -10,7 +10,9 @@ defmodule BlockScoutWeb.AddressControllerTest do
conn = get(conn, address_path(conn, :index)) conn = get(conn, address_path(conn, :index))
assert conn.assigns.addresses |> Enum.map(& &1.hash) == address_hashes assert conn.assigns.address_tx_count_pairs
|> Enum.map(fn {address, _transaction_count} -> address end)
|> Enum.map(& &1.hash) == address_hashes
end end
end end

@ -923,14 +923,15 @@ defmodule Explorer.Chain do
@spec list_top_addresses :: [{Address.t(), non_neg_integer()}] @spec list_top_addresses :: [{Address.t(), non_neg_integer()}]
def list_top_addresses do def list_top_addresses do
query = query =
from a in Address, from(a in Address,
left_join: t in Transaction, left_join: t in Transaction,
on: a.hash == t.from_address_hash, on: a.hash == t.from_address_hash,
where: a.fetched_coin_balance > ^0, where: a.fetched_coin_balance > ^0,
group_by: [a.hash, a.fetched_coin_balance], group_by: [a.hash, a.fetched_coin_balance],
order_by: [desc: a.fetched_coin_balance, asc: a.hash], order_by: [desc: a.fetched_coin_balance, asc: a.hash],
select: {a, fragment("coalesce(1 + max(?), 0)", t.nonce)}, select: {a, fragment("coalesce(1 + max(?), 0)", t.nonce)},
limit: 250 limit: 250
)
Repo.all(query) Repo.all(query)
end end

@ -1183,9 +1183,9 @@ defmodule Explorer.ChainTest do
|> Enum.map(& &1.hash) |> Enum.map(& &1.hash)
assert address_hashes == assert address_hashes ==
Chain.list_top_addresses() Chain.list_top_addresses()
|> Enum.map(fn {address, _transaction_count} -> address end) |> Enum.map(fn {address, _transaction_count} -> address end)
|> Enum.map(& &1.hash) |> Enum.map(& &1.hash)
end end
test "with top addresses in order with matching value" do test "with top addresses in order with matching value" do
@ -1205,9 +1205,9 @@ defmodule Explorer.ChainTest do
|> Map.fetch!(:hash) |> Map.fetch!(:hash)
assert [first_result_hash | tail] == assert [first_result_hash | tail] ==
Chain.list_top_addresses() Chain.list_top_addresses()
|> Enum.map(fn {address, _transaction_count} -> address end) |> Enum.map(fn {address, _transaction_count} -> address end)
|> Enum.map(& &1.hash) |> Enum.map(& &1.hash)
end end
end end

Loading…
Cancel
Save