Process reviewr comments

pull/2862/head
Victor Baranov 5 years ago
parent b87fc2d7ab
commit d81f094048
  1. 7
      apps/explorer/lib/explorer/chain.ex
  2. 14
      apps/explorer/test/explorer/chain_test.exs

@ -1324,16 +1324,13 @@ defmodule Explorer.Chain do
@spec fetch_sum_coin_total_supply() :: non_neg_integer
def fetch_sum_coin_total_supply do
{:ok, burn_address_hash} = Explorer.Chain.string_to_address_hash("0x0000000000000000000000000000000000000000")
query =
from(
a0 in Address,
select: fragment("SUM(a0.fetched_coin_balance)"),
where: a0.hash != ^burn_address_hash
select: fragment("SUM(a0.fetched_coin_balance)")
)
Repo.one!(query)
Repo.one!(query) || 0
end
@doc """

@ -1121,6 +1121,20 @@ defmodule Explorer.ChainTest do
end
end
describe "fetch_sum_coin_total_supply/0" do
test "fetches coin total supply" do
for index <- 0..4 do
insert(:address, fetched_coin_balance: index)
end
assert "10" = Decimal.to_string(Chain.fetch_sum_coin_total_supply())
end
test "fetches coin total supply when there are no blocks" do
assert 0 = Chain.fetch_sum_coin_total_supply()
end
end
describe "address_hash_to_token_transfers/2" do
test "returns just the token transfers related to the given contract address" do
contract_address =

Loading…
Cancel
Save