|
|
@ -383,13 +383,13 @@ defmodule Explorer.ChainTest do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "address_to_mined_transactions_with_rewards/2" do |
|
|
|
describe "address_to_transactions_with_rewards/2" do |
|
|
|
test "without transactions" do |
|
|
|
test "without transactions" do |
|
|
|
%Address{hash: address_hash} = insert(:address) |
|
|
|
%Address{hash: address_hash} = insert(:address) |
|
|
|
|
|
|
|
|
|
|
|
assert Repo.aggregate(Transaction, :count, :hash) == 0 |
|
|
|
assert Repo.aggregate(Transaction, :count, :hash) == 0 |
|
|
|
|
|
|
|
|
|
|
|
assert [] == Chain.address_to_mined_transactions_with_rewards(address_hash) |
|
|
|
assert [] == Chain.address_to_transactions_with_rewards(address_hash) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
test "with from transactions" do |
|
|
|
test "with from transactions" do |
|
|
@ -401,7 +401,7 @@ defmodule Explorer.ChainTest do |
|
|
|
|> with_block() |
|
|
|
|> with_block() |
|
|
|
|
|
|
|
|
|
|
|
assert [transaction] == |
|
|
|
assert [transaction] == |
|
|
|
Chain.address_to_mined_transactions_with_rewards(address_hash, direction: :from) |
|
|
|
Chain.address_to_transactions_with_rewards(address_hash, direction: :from) |
|
|
|
|> Repo.preload([:block, :to_address, :from_address]) |
|
|
|
|> Repo.preload([:block, :to_address, :from_address]) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -414,7 +414,7 @@ defmodule Explorer.ChainTest do |
|
|
|
|> with_block() |
|
|
|
|> with_block() |
|
|
|
|
|
|
|
|
|
|
|
assert [transaction] == |
|
|
|
assert [transaction] == |
|
|
|
Chain.address_to_mined_transactions_with_rewards(address_hash, direction: :to) |
|
|
|
Chain.address_to_transactions_with_rewards(address_hash, direction: :to) |
|
|
|
|> Repo.preload([:block, :to_address, :from_address]) |
|
|
|
|> Repo.preload([:block, :to_address, :from_address]) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -428,7 +428,7 @@ defmodule Explorer.ChainTest do |
|
|
|
|
|
|
|
|
|
|
|
# only contains "from" transaction |
|
|
|
# only contains "from" transaction |
|
|
|
assert [transaction] == |
|
|
|
assert [transaction] == |
|
|
|
Chain.address_to_mined_transactions_with_rewards(address_hash, direction: :from) |
|
|
|
Chain.address_to_transactions_with_rewards(address_hash, direction: :from) |
|
|
|
|> Repo.preload([:block, :to_address, :from_address]) |
|
|
|
|> Repo.preload([:block, :to_address, :from_address]) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -441,7 +441,7 @@ defmodule Explorer.ChainTest do |
|
|
|
|> with_block() |
|
|
|
|> with_block() |
|
|
|
|
|
|
|
|
|
|
|
assert [transaction] == |
|
|
|
assert [transaction] == |
|
|
|
Chain.address_to_mined_transactions_with_rewards(address_hash, direction: :to) |
|
|
|
Chain.address_to_transactions_with_rewards(address_hash, direction: :to) |
|
|
|
|> Repo.preload([:block, :to_address, :from_address]) |
|
|
|
|> Repo.preload([:block, :to_address, :from_address]) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -460,7 +460,7 @@ defmodule Explorer.ChainTest do |
|
|
|
|> with_block(block) |
|
|
|
|> with_block(block) |
|
|
|
|
|
|
|
|
|
|
|
assert [transaction2, transaction1] == |
|
|
|
assert [transaction2, transaction1] == |
|
|
|
Chain.address_to_mined_transactions_with_rewards(address_hash) |
|
|
|
Chain.address_to_transactions_with_rewards(address_hash) |
|
|
|
|> Repo.preload([:block, :to_address, :from_address]) |
|
|
|
|> Repo.preload([:block, :to_address, :from_address]) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -481,7 +481,7 @@ defmodule Explorer.ChainTest do |
|
|
|
transaction_index: transaction.index |
|
|
|
transaction_index: transaction.index |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
assert [] == Chain.address_to_mined_transactions_with_rewards(address.hash) |
|
|
|
assert [] == Chain.address_to_transactions_with_rewards(address.hash) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
test "returns transactions that have token transfers for the given to_address" do |
|
|
|
test "returns transactions that have token transfers for the given to_address" do |
|
|
@ -499,7 +499,7 @@ defmodule Explorer.ChainTest do |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
assert [transaction.hash] == |
|
|
|
assert [transaction.hash] == |
|
|
|
Chain.address_to_mined_transactions_with_rewards(address_hash) |
|
|
|
Chain.address_to_transactions_with_rewards(address_hash) |
|
|
|
|> Enum.map(& &1.hash) |
|
|
|
|> Enum.map(& &1.hash) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -519,7 +519,7 @@ defmodule Explorer.ChainTest do |
|
|
|
|
|
|
|
|
|
|
|
assert second_page_hashes == |
|
|
|
assert second_page_hashes == |
|
|
|
address_hash |
|
|
|
address_hash |
|
|
|
|> Chain.address_to_mined_transactions_with_rewards( |
|
|
|
|> Chain.address_to_transactions_with_rewards( |
|
|
|
paging_options: %PagingOptions{ |
|
|
|
paging_options: %PagingOptions{ |
|
|
|
key: {block_number, index}, |
|
|
|
key: {block_number, index}, |
|
|
|
page_size: 2 |
|
|
|
page_size: 2 |
|
|
@ -568,7 +568,7 @@ defmodule Explorer.ChainTest do |
|
|
|
|
|
|
|
|
|
|
|
result = |
|
|
|
result = |
|
|
|
address_hash |
|
|
|
address_hash |
|
|
|
|> Chain.address_to_mined_transactions_with_rewards() |
|
|
|
|> Chain.address_to_transactions_with_rewards() |
|
|
|
|> Enum.map(& &1.hash) |
|
|
|
|> Enum.map(& &1.hash) |
|
|
|
|
|
|
|
|
|
|
|
assert [fourth, third, second, first, sixth, fifth] == result |
|
|
|
assert [fourth, third, second, first, sixth, fifth] == result |
|
|
@ -619,7 +619,7 @@ defmodule Explorer.ChainTest do |
|
|
|
end |
|
|
|
end |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
res = Chain.address_to_mined_transactions_with_rewards(block.miner.hash) |
|
|
|
res = Chain.address_to_transactions_with_rewards(block.miner.hash) |
|
|
|
|
|
|
|
|
|
|
|
assert [{_, _}] = res |
|
|
|
assert [{_, _}] = res |
|
|
|
|
|
|
|
|
|
|
@ -683,7 +683,7 @@ defmodule Explorer.ChainTest do |
|
|
|
end |
|
|
|
end |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
assert [_, {_, _}] = Chain.address_to_mined_transactions_with_rewards(block.miner.hash, direction: :to) |
|
|
|
assert [_, {_, _}] = Chain.address_to_transactions_with_rewards(block.miner.hash, direction: :to) |
|
|
|
|
|
|
|
|
|
|
|
on_exit(fn -> |
|
|
|
on_exit(fn -> |
|
|
|
Application.put_env(:block_scout_web, BlockScoutWeb.Chain, has_emission_funds: false) |
|
|
|
Application.put_env(:block_scout_web, BlockScoutWeb.Chain, has_emission_funds: false) |
|
|
@ -719,7 +719,7 @@ defmodule Explorer.ChainTest do |
|
|
|
|> with_block() |
|
|
|
|> with_block() |
|
|
|
|> Repo.preload(:token_transfers) |
|
|
|
|> Repo.preload(:token_transfers) |
|
|
|
|
|
|
|
|
|
|
|
assert [_] = Chain.address_to_mined_transactions_with_rewards(block.miner.hash, direction: :from) |
|
|
|
assert [_] = Chain.address_to_transactions_with_rewards(block.miner.hash, direction: :from) |
|
|
|
|
|
|
|
|
|
|
|
Application.put_env(:block_scout_web, BlockScoutWeb.Chain, has_emission_funds: false) |
|
|
|
Application.put_env(:block_scout_web, BlockScoutWeb.Chain, has_emission_funds: false) |
|
|
|
end |
|
|
|
end |
|
|
@ -743,7 +743,7 @@ defmodule Explorer.ChainTest do |
|
|
|
address_type: :emission_funds |
|
|
|
address_type: :emission_funds |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
assert [] == Chain.address_to_mined_transactions_with_rewards(block.miner.hash) |
|
|
|
assert [] == Chain.address_to_transactions_with_rewards(block.miner.hash) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|