|
|
@ -13,10 +13,13 @@ defmodule Explorer.SmartContract.Solidity.PublisherTest do |
|
|
|
|
|
|
|
|
|
|
|
describe "publish/2" do |
|
|
|
describe "publish/2" do |
|
|
|
test "with valid data creates a smart_contract" do |
|
|
|
test "with valid data creates a smart_contract" do |
|
|
|
contract_code_info = Factory.contract_code_info() |
|
|
|
contract_code_info = Factory.contract_code_info_modern_compilator() |
|
|
|
|
|
|
|
|
|
|
|
contract_address = insert(:contract_address, contract_code: contract_code_info.bytecode) |
|
|
|
contract_address = insert(:contract_address, contract_code: contract_code_info.bytecode) |
|
|
|
insert(:transaction, created_contract_address_hash: contract_address.hash, input: contract_code_info.tx_input) |
|
|
|
|
|
|
|
|
|
|
|
:transaction |
|
|
|
|
|
|
|
|> insert(created_contract_address_hash: contract_address.hash, input: contract_code_info.tx_input) |
|
|
|
|
|
|
|
|> with_block(status: :ok) |
|
|
|
|
|
|
|
|
|
|
|
valid_attrs = %{ |
|
|
|
valid_attrs = %{ |
|
|
|
"contract_source_code" => contract_code_info.source_code, |
|
|
|
"contract_source_code" => contract_code_info.source_code, |
|
|
@ -57,7 +60,7 @@ defmodule Explorer.SmartContract.Solidity.PublisherTest do |
|
|
|
created_contract_address_hash: contract_address.hash, |
|
|
|
created_contract_address_hash: contract_address.hash, |
|
|
|
input: input <> expected_constructor_arguments |
|
|
|
input: input <> expected_constructor_arguments |
|
|
|
) |
|
|
|
) |
|
|
|
|> with_block() |
|
|
|
|> with_block(status: :ok) |
|
|
|
|
|
|
|
|
|
|
|
params = %{ |
|
|
|
params = %{ |
|
|
|
"contract_source_code" => contract, |
|
|
|
"contract_source_code" => contract, |
|
|
@ -73,10 +76,13 @@ defmodule Explorer.SmartContract.Solidity.PublisherTest do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
test "corresponding contract_methods are created for the abi" do |
|
|
|
test "corresponding contract_methods are created for the abi" do |
|
|
|
contract_code_info = Factory.contract_code_info() |
|
|
|
contract_code_info = Factory.contract_code_info_modern_compilator() |
|
|
|
|
|
|
|
|
|
|
|
contract_address = insert(:contract_address, contract_code: contract_code_info.bytecode) |
|
|
|
contract_address = insert(:contract_address, contract_code: contract_code_info.bytecode) |
|
|
|
insert(:transaction, created_contract_address_hash: contract_address.hash, input: contract_code_info.tx_input) |
|
|
|
|
|
|
|
|
|
|
|
:transaction |
|
|
|
|
|
|
|
|> insert(created_contract_address_hash: contract_address.hash, input: contract_code_info.tx_input) |
|
|
|
|
|
|
|
|> with_block(status: :ok) |
|
|
|
|
|
|
|
|
|
|
|
valid_attrs = %{ |
|
|
|
valid_attrs = %{ |
|
|
|
"contract_source_code" => contract_code_info.source_code, |
|
|
|
"contract_source_code" => contract_code_info.source_code, |
|
|
@ -96,7 +102,7 @@ defmodule Explorer.SmartContract.Solidity.PublisherTest do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
test "creates a smart contract with constructor arguments" do |
|
|
|
test "creates a smart contract with constructor arguments" do |
|
|
|
contract_code_info = Factory.contract_code_info() |
|
|
|
contract_code_info = Factory.contract_code_info_modern_compilator() |
|
|
|
|
|
|
|
|
|
|
|
contract_address = insert(:contract_address, contract_code: contract_code_info.bytecode) |
|
|
|
contract_address = insert(:contract_address, contract_code: contract_code_info.bytecode) |
|
|
|
|
|
|
|
|
|
|
@ -115,7 +121,7 @@ defmodule Explorer.SmartContract.Solidity.PublisherTest do |
|
|
|
created_contract_address_hash: contract_address.hash, |
|
|
|
created_contract_address_hash: contract_address.hash, |
|
|
|
input: contract_code_info.tx_input <> constructor_arguments |
|
|
|
input: contract_code_info.tx_input <> constructor_arguments |
|
|
|
) |
|
|
|
) |
|
|
|
|> with_block() |
|
|
|
|> with_block(status: :ok) |
|
|
|
|
|
|
|
|
|
|
|
response = Publisher.publish(contract_address.hash, params) |
|
|
|
response = Publisher.publish(contract_address.hash, params) |
|
|
|
assert {:ok, %SmartContract{} = smart_contract} = response |
|
|
|
assert {:ok, %SmartContract{} = smart_contract} = response |
|
|
@ -152,7 +158,10 @@ defmodule Explorer.SmartContract.Solidity.PublisherTest do |
|
|
|
tx_input = contract_data["tx_input"] |
|
|
|
tx_input = contract_data["tx_input"] |
|
|
|
|
|
|
|
|
|
|
|
contract_address = insert(:contract_address, contract_code: "0x" <> expected_bytecode) |
|
|
|
contract_address = insert(:contract_address, contract_code: "0x" <> expected_bytecode) |
|
|
|
insert(:transaction, created_contract_address_hash: contract_address.hash, input: "0x" <> tx_input) |
|
|
|
|
|
|
|
|
|
|
|
:transaction |
|
|
|
|
|
|
|
|> insert(created_contract_address_hash: contract_address.hash, input: "0x" <> tx_input) |
|
|
|
|
|
|
|
|> with_block(status: :ok) |
|
|
|
|
|
|
|
|
|
|
|
params = %{ |
|
|
|
params = %{ |
|
|
|
"contract_source_code" => contract, |
|
|
|
"contract_source_code" => contract, |
|
|
|