|
|
|
@ -158,6 +158,46 @@ defmodule Explorer.Etherscan.LogsTest do |
|
|
|
|
assert found_log.transaction_hash == transaction_block1.hash |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
test "paginates logs" do |
|
|
|
|
contract_address = insert(:contract_address) |
|
|
|
|
|
|
|
|
|
transaction = |
|
|
|
|
%Transaction{block: block} = |
|
|
|
|
:transaction |
|
|
|
|
|> insert(to_address: contract_address) |
|
|
|
|
|> with_block() |
|
|
|
|
|
|
|
|
|
inserted_records = insert_list(2000, :log, address: contract_address, transaction: transaction) |
|
|
|
|
|
|
|
|
|
filter = %{ |
|
|
|
|
from_block: block.number, |
|
|
|
|
to_block: block.number, |
|
|
|
|
address_hash: contract_address.hash |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
first_found_logs = Logs.list_logs(filter) |
|
|
|
|
|
|
|
|
|
assert Enum.count(first_found_logs) == 1_000 |
|
|
|
|
|
|
|
|
|
last_record = List.last(first_found_logs) |
|
|
|
|
|
|
|
|
|
next_page_params = %{ |
|
|
|
|
log_index: last_record.index, |
|
|
|
|
transaction_index: last_record.transaction_index, |
|
|
|
|
block_number: transaction.block_number |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
second_found_logs = Logs.list_logs(filter, next_page_params) |
|
|
|
|
|
|
|
|
|
assert Enum.count(second_found_logs) == 1_000 |
|
|
|
|
|
|
|
|
|
all_found_logs = first_found_logs ++ second_found_logs |
|
|
|
|
|
|
|
|
|
Enum.all?(inserted_records, fn record -> |
|
|
|
|
Enum.any?(all_found_logs, fn found_log -> found_log.index == record.index end) |
|
|
|
|
end) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
test "with a valid topic{x}" do |
|
|
|
|
contract_address = insert(:contract_address) |
|
|
|
|
|
|
|
|
|