|
|
@ -565,6 +565,61 @@ defmodule Explorer.Chain.ImportTest do |
|
|
|
assert address.contract_code != smart_contract_bytecode |
|
|
|
assert address.contract_code != smart_contract_bytecode |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test "updates `error`, `status` and `internal_transaction_indexed_at` even if internal transactions were alreader inserted" do |
|
|
|
|
|
|
|
address_hash = "0x1c494fa496f1cfd918b5ff190835af3aaf609899" |
|
|
|
|
|
|
|
from_address = insert(:address, hash: address_hash) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
block = insert(:block, consensus: true) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
transaction = |
|
|
|
|
|
|
|
:transaction |
|
|
|
|
|
|
|
|> insert(error: nil, internal_transactions_indexed_at: nil, status: nil, from_address: from_address, status: 0) |
|
|
|
|
|
|
|
|> with_block(block, status: :error) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal_transacton = |
|
|
|
|
|
|
|
insert(:internal_transaction, |
|
|
|
|
|
|
|
transaction_hash: transaction.hash, |
|
|
|
|
|
|
|
error: "Bad Instruction", |
|
|
|
|
|
|
|
index: 0, |
|
|
|
|
|
|
|
gas_used: nil, |
|
|
|
|
|
|
|
output: nil, |
|
|
|
|
|
|
|
gas: 19, |
|
|
|
|
|
|
|
type: "call" |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
options = %{ |
|
|
|
|
|
|
|
internal_transactions: %{ |
|
|
|
|
|
|
|
params: [ |
|
|
|
|
|
|
|
%{ |
|
|
|
|
|
|
|
block_number: internal_transacton.block_number, |
|
|
|
|
|
|
|
call_type: internal_transacton.type, |
|
|
|
|
|
|
|
gas: internal_transacton.gas, |
|
|
|
|
|
|
|
gas_used: internal_transacton.gas_used, |
|
|
|
|
|
|
|
index: internal_transacton.index, |
|
|
|
|
|
|
|
output: internal_transacton.output, |
|
|
|
|
|
|
|
transaction_hash: internal_transacton.transaction_hash, |
|
|
|
|
|
|
|
type: internal_transacton.type, |
|
|
|
|
|
|
|
from_address_hash: address_hash, |
|
|
|
|
|
|
|
to_address_hash: address_hash, |
|
|
|
|
|
|
|
trace_address: [], |
|
|
|
|
|
|
|
value: 0, |
|
|
|
|
|
|
|
transaction_index: 0, |
|
|
|
|
|
|
|
error: internal_transacton.error, |
|
|
|
|
|
|
|
input: internal_transacton.input |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{:ok, _} = Import.all(options) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert result = |
|
|
|
|
|
|
|
%Transaction{error: "Bad Instruction", status: :error} = |
|
|
|
|
|
|
|
Repo.one!(from(t in Transaction, where: t.hash == ^transaction.hash)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert result.internal_transactions_indexed_at |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
test "with internal_transactions updates Transaction internal_transactions_indexed_at" do |
|
|
|
test "with internal_transactions updates Transaction internal_transactions_indexed_at" do |
|
|
|
block_hash = "0xe52d77084cab13a4e724162bcd8c6028e5ecfaa04d091ee476e96b9958ed6b47" |
|
|
|
block_hash = "0xe52d77084cab13a4e724162bcd8c6028e5ecfaa04d091ee476e96b9958ed6b47" |
|
|
|
block_number = 34 |
|
|
|
block_number = 34 |
|
|
|