Set up contract verification test with `create` internal transaction
pull/441/head
Tim Mecklem 6 years ago committed by GitHub
commit 2a56a6e0b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      apps/explorer/test/support/factory.ex
  2. 16
      apps/explorer_web/test/explorer_web/features/address_contract_verification_test.exs

@ -29,13 +29,6 @@ defmodule Explorer.Factory do
} }
end end
def contract_address_factory do
%Address{
hash: address_hash(),
contract_code: Map.fetch!(contract_code_info(), :bytecode)
}
end
def contract_code_info do def contract_code_info do
%{ %{
bytecode: bytecode:
@ -187,9 +180,11 @@ defmodule Explorer.Factory do
gas = Enum.random(21_000..100_000) gas = Enum.random(21_000..100_000)
gas_used = Enum.random(0..gas) gas_used = Enum.random(0..gas)
contract_code = Map.fetch!(contract_code_info(), :bytecode)
%InternalTransaction{ %InternalTransaction{
created_contract_code: data(:internal_transaction_created_contract_code), created_contract_code: contract_code,
created_contract_address: build(:address), created_contract_address: build(:address, contract_code: contract_code),
from_address: build(:address), from_address: build(:address),
gas: gas, gas: gas,
gas_used: gas_used, gas_used: gas_used,

@ -4,6 +4,7 @@ defmodule ExplorerWeb.AddressContractVerificationTest do
import Wallaby.Query import Wallaby.Query
alias Plug.Conn alias Plug.Conn
alias Explorer.Chain.Address
alias Explorer.Factory alias Explorer.Factory
setup do setup do
@ -19,17 +20,26 @@ defmodule ExplorerWeb.AddressContractVerificationTest do
%{name: name, source_code: source_code, bytecode: bytecode, version: version} = Factory.contract_code_info() %{name: name, source_code: source_code, bytecode: bytecode, version: version} = Factory.contract_code_info()
contract_address = insert(:contract_address, contract_code: bytecode) transaction = :transaction |> insert() |> with_block()
address = %Address{hash: address_hash} = insert(:address, contract_code: bytecode)
insert(
:internal_transaction_create,
created_contract_address: address,
created_contract_code: bytecode,
index: 0,
transaction: transaction
)
session session
|> visit("/en/addresses/#{contract_address.hash}/contract_verifications/new") |> visit("/en/addresses/#{address_hash}/contract_verifications/new")
|> fill_in(text_field("Contract Name"), with: name) |> fill_in(text_field("Contract Name"), with: name)
|> click(option(version)) |> click(option(version))
|> click(radio_button("No")) |> click(radio_button("No"))
|> fill_in(text_field("Enter the Solidity Contract Code below"), with: source_code) |> fill_in(text_field("Enter the Solidity Contract Code below"), with: source_code)
|> click(button("Verify and publish")) |> click(button("Verify and publish"))
assert current_path(session) =~ ~r/\/en\/addresses\/#{contract_address.hash}\/contracts/ assert current_path(session) =~ ~r/\/en\/addresses\/#{address_hash}\/contracts/
end end
test "with invalid data shows error messages", %{session: session, bypass: bypass} do test "with invalid data shows error messages", %{session: session, bypass: bypass} do

Loading…
Cancel
Save