|
|
|
@ -6,6 +6,25 @@ defmodule Explorer.Etherscan.LogsTest do |
|
|
|
|
alias Explorer.Etherscan.Logs |
|
|
|
|
alias Explorer.Chain.Transaction |
|
|
|
|
|
|
|
|
|
@first_topic_hex_string_1 "0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65" |
|
|
|
|
@first_topic_hex_string_2 "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" |
|
|
|
|
@first_topic_hex_string_3 "0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c" |
|
|
|
|
|
|
|
|
|
@second_topic_hex_string_1 "0x00000000000000000000000098a9dc37d3650b5b30d6c12789b3881ee0b70c16" |
|
|
|
|
@second_topic_hex_string_2 "0x000000000000000000000000e2680fd7cdbb04e9087a647ad4d023ef6c8fb4e2" |
|
|
|
|
@second_topic_hex_string_3 "0x0000000000000000000000005777d92f208679db4b9778590fa3cab3ac9e2168" |
|
|
|
|
|
|
|
|
|
@third_topic_hex_string_1 "0x0000000000000000000000005079fc00f00f30000e0c8c083801cfde000008b6" |
|
|
|
|
@third_topic_hex_string_2 "0x000000000000000000000000e2680fd7cdbb04e9087a647ad4d023ef6c8fb4e2" |
|
|
|
|
@third_topic_hex_string_3 "0x0000000000000000000000000f6d9bd6fc315bbf95b5c44f4eba2b2762f8c372" |
|
|
|
|
|
|
|
|
|
@fourth_topic_hex_string_1 "0x8c9b7729443a4444242342b2ca385a239a5c1d76a88473e1cd2ab0c70dd1b9c7" |
|
|
|
|
|
|
|
|
|
defp topic(topic_hex_string) do |
|
|
|
|
{:ok, topic} = Explorer.Chain.Hash.Full.cast(topic_hex_string) |
|
|
|
|
topic |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "list_logs/1" do |
|
|
|
|
test "with empty db" do |
|
|
|
|
contract_address = build(:contract_address) |
|
|
|
@ -211,13 +230,13 @@ defmodule Explorer.Etherscan.LogsTest do |
|
|
|
|
log1_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some topic" |
|
|
|
|
first_topic: topic(@first_topic_hex_string_1) |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
log2_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some other topic" |
|
|
|
|
first_topic: topic(@first_topic_hex_string_2) |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
log1 = insert(:log, log1_details) |
|
|
|
@ -247,15 +266,15 @@ defmodule Explorer.Etherscan.LogsTest do |
|
|
|
|
log1_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some first topic", |
|
|
|
|
second_topic: "some second topic" |
|
|
|
|
first_topic: topic(@first_topic_hex_string_1), |
|
|
|
|
second_topic: topic(@second_topic_hex_string_1) |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
log2_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some first topic", |
|
|
|
|
second_topic: "some OTHER second topic" |
|
|
|
|
first_topic: topic(@first_topic_hex_string_1), |
|
|
|
|
second_topic: topic(@second_topic_hex_string_2) |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
_log1 = insert(:log, log1_details) |
|
|
|
@ -288,15 +307,15 @@ defmodule Explorer.Etherscan.LogsTest do |
|
|
|
|
log1_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some first topic", |
|
|
|
|
second_topic: "some second topic" |
|
|
|
|
first_topic: topic(@first_topic_hex_string_1), |
|
|
|
|
second_topic: topic(@second_topic_hex_string_1) |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
log2_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some OTHER first topic", |
|
|
|
|
second_topic: "some OTHER second topic" |
|
|
|
|
first_topic: topic(@first_topic_hex_string_2), |
|
|
|
|
second_topic: topic(@second_topic_hex_string_2) |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
log1 = insert(:log, log1_details) |
|
|
|
@ -327,14 +346,14 @@ defmodule Explorer.Etherscan.LogsTest do |
|
|
|
|
log1_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some first topic", |
|
|
|
|
first_topic: topic(@first_topic_hex_string_1), |
|
|
|
|
block_number: block.number |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
log2_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some OTHER first topic", |
|
|
|
|
first_topic: topic(@first_topic_hex_string_2), |
|
|
|
|
block_number: block.number |
|
|
|
|
] |
|
|
|
|
|
|
|
|
@ -366,16 +385,16 @@ defmodule Explorer.Etherscan.LogsTest do |
|
|
|
|
log1_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some first topic", |
|
|
|
|
second_topic: "some second topic", |
|
|
|
|
first_topic: topic(@first_topic_hex_string_1), |
|
|
|
|
second_topic: topic(@second_topic_hex_string_1), |
|
|
|
|
block_number: block.number |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
log2_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some OTHER first topic", |
|
|
|
|
second_topic: "some OTHER second topic", |
|
|
|
|
first_topic: topic(@first_topic_hex_string_2), |
|
|
|
|
second_topic: topic(@second_topic_hex_string_2), |
|
|
|
|
block_number: block.number |
|
|
|
|
] |
|
|
|
|
|
|
|
|
@ -409,27 +428,27 @@ defmodule Explorer.Etherscan.LogsTest do |
|
|
|
|
log1_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some first topic", |
|
|
|
|
second_topic: "some second topic", |
|
|
|
|
third_topic: "some third topic", |
|
|
|
|
first_topic: topic(@first_topic_hex_string_1), |
|
|
|
|
second_topic: topic(@second_topic_hex_string_1), |
|
|
|
|
third_topic: topic(@third_topic_hex_string_1), |
|
|
|
|
block_number: block.number |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
log2_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some OTHER first topic", |
|
|
|
|
second_topic: "some OTHER second topic", |
|
|
|
|
third_topic: "some OTHER third topic", |
|
|
|
|
first_topic: topic(@first_topic_hex_string_2), |
|
|
|
|
second_topic: topic(@second_topic_hex_string_2), |
|
|
|
|
third_topic: topic(@third_topic_hex_string_2), |
|
|
|
|
block_number: block.number |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
log3_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some ALT first topic", |
|
|
|
|
second_topic: "some ALT second topic", |
|
|
|
|
third_topic: "some ALT third topic", |
|
|
|
|
first_topic: topic(@first_topic_hex_string_3), |
|
|
|
|
second_topic: topic(@second_topic_hex_string_3), |
|
|
|
|
third_topic: topic(@third_topic_hex_string_3), |
|
|
|
|
block_number: block.number |
|
|
|
|
] |
|
|
|
|
|
|
|
|
@ -469,27 +488,27 @@ defmodule Explorer.Etherscan.LogsTest do |
|
|
|
|
log1_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some first topic", |
|
|
|
|
second_topic: "some second topic", |
|
|
|
|
third_topic: "some third topic", |
|
|
|
|
first_topic: topic(@first_topic_hex_string_1), |
|
|
|
|
second_topic: topic(@second_topic_hex_string_1), |
|
|
|
|
third_topic: topic(@third_topic_hex_string_1), |
|
|
|
|
block_number: block.number |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
log2_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some OTHER first topic", |
|
|
|
|
second_topic: "some OTHER second topic", |
|
|
|
|
third_topic: "some OTHER third topic", |
|
|
|
|
first_topic: topic(@first_topic_hex_string_2), |
|
|
|
|
second_topic: topic(@second_topic_hex_string_2), |
|
|
|
|
third_topic: topic(@third_topic_hex_string_2), |
|
|
|
|
block_number: block.number |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
log3_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some ALT first topic", |
|
|
|
|
second_topic: "some ALT second topic", |
|
|
|
|
third_topic: "some ALT third topic", |
|
|
|
|
first_topic: topic(@first_topic_hex_string_3), |
|
|
|
|
second_topic: topic(@second_topic_hex_string_3), |
|
|
|
|
third_topic: topic(@third_topic_hex_string_3), |
|
|
|
|
block_number: block.number |
|
|
|
|
] |
|
|
|
|
|
|
|
|
@ -529,27 +548,27 @@ defmodule Explorer.Etherscan.LogsTest do |
|
|
|
|
log1_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some topic", |
|
|
|
|
second_topic: "some second topic", |
|
|
|
|
third_topic: "some third topic", |
|
|
|
|
first_topic: topic(@first_topic_hex_string_1), |
|
|
|
|
second_topic: topic(@second_topic_hex_string_1), |
|
|
|
|
third_topic: topic(@third_topic_hex_string_1), |
|
|
|
|
block_number: block.number |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
log2_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some topic", |
|
|
|
|
second_topic: "some OTHER second topic", |
|
|
|
|
third_topic: "some third topic", |
|
|
|
|
first_topic: topic(@first_topic_hex_string_1), |
|
|
|
|
second_topic: topic(@second_topic_hex_string_2), |
|
|
|
|
third_topic: topic(@third_topic_hex_string_1), |
|
|
|
|
block_number: block.number |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
log3_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some topic", |
|
|
|
|
second_topic: "some second topic", |
|
|
|
|
third_topic: "some third topic", |
|
|
|
|
first_topic: topic(@first_topic_hex_string_1), |
|
|
|
|
second_topic: topic(@second_topic_hex_string_1), |
|
|
|
|
third_topic: topic(@third_topic_hex_string_1), |
|
|
|
|
block_number: block.number |
|
|
|
|
] |
|
|
|
|
|
|
|
|
@ -589,28 +608,28 @@ defmodule Explorer.Etherscan.LogsTest do |
|
|
|
|
log1_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some topic", |
|
|
|
|
second_topic: "some second topic", |
|
|
|
|
first_topic: topic(@first_topic_hex_string_1), |
|
|
|
|
second_topic: topic(@second_topic_hex_string_1), |
|
|
|
|
block_number: block.number |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
log2_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some OTHER topic", |
|
|
|
|
second_topic: "some OTHER second topic", |
|
|
|
|
third_topic: "some OTHER third topic", |
|
|
|
|
fourth_topic: "some fourth topic", |
|
|
|
|
first_topic: topic(@first_topic_hex_string_2), |
|
|
|
|
second_topic: topic(@second_topic_hex_string_2), |
|
|
|
|
third_topic: topic(@third_topic_hex_string_2), |
|
|
|
|
fourth_topic: topic(@fourth_topic_hex_string_1), |
|
|
|
|
block_number: block.number |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
log3_details = [ |
|
|
|
|
address: contract_address, |
|
|
|
|
transaction: transaction, |
|
|
|
|
first_topic: "some topic", |
|
|
|
|
second_topic: "some second topic", |
|
|
|
|
third_topic: "some third topic", |
|
|
|
|
fourth_topic: "some fourth topic", |
|
|
|
|
first_topic: topic(@first_topic_hex_string_1), |
|
|
|
|
second_topic: topic(@second_topic_hex_string_1), |
|
|
|
|
third_topic: topic(@third_topic_hex_string_1), |
|
|
|
|
fourth_topic: topic(@fourth_topic_hex_string_1), |
|
|
|
|
block_number: block.number |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|