Skip to content

Commit

Permalink
address linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
wolovim committed Jul 24, 2020
1 parent ab9438f commit 60cccbc
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 17 deletions.
4 changes: 0 additions & 4 deletions tests/core/contracts/test_contract_call_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,6 @@ def nested_tuple_contract(web3, NestedTupleContract, address_conversion_func):
return deploy(web3, NestedTupleContract, address_conversion_func)


@pytest.fixture()
def revert_contract(web3, RevertContract, address_conversion_func):
return deploy(web3, RevertContract, address_conversion_func)

def test_invalid_address_in_deploy_arg(web3, WithConstructorAddressArgumentsContract):
with pytest.raises(InvalidAddress):
WithConstructorAddressArgumentsContract.constructor(
Expand Down
2 changes: 1 addition & 1 deletion tests/generate_go_ethereum_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
MATH_BYTECODE,
)
from web3._utils.module_testing.revert_contract import (
REVERT_CONTRACT_BYTECODE,
_REVERT_CONTRACT_ABI,
REVERT_CONTRACT_BYTECODE,
)

COINBASE = '0xdc544d1aa88ff8bbd2f2aec754b1f1e99e1812fd'
Expand Down
8 changes: 6 additions & 2 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ def math_contract_factory(web3):

@pytest.fixture(scope="module")
def emitter_contract_factory(web3):
contract_factory = web3.eth.contract(abi=CONTRACT_EMITTER_ABI, bytecode=CONTRACT_EMITTER_CODE)
contract_factory = web3.eth.contract(
abi=CONTRACT_EMITTER_ABI, bytecode=CONTRACT_EMITTER_CODE
)
return contract_factory


@pytest.fixture(scope="module")
def revert_contract_factory(web3):
contract_factory = web3.eth.contract(abi=_REVERT_CONTRACT_ABI, bytecode=REVERT_CONTRACT_BYTECODE)
contract_factory = web3.eth.contract(
abi=_REVERT_CONTRACT_ABI, bytecode=REVERT_CONTRACT_BYTECODE
)
return contract_factory


Expand Down
3 changes: 2 additions & 1 deletion tests/integration/generate_fixtures/parity.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ def generate_parity_fixture(destination_dir):
geth_ipc_path,
geth_port,
str(CHAIN_CONFIG['params']['networkID'])
))
)
)
# set up fixtures
common.wait_for_socket(geth_ipc_path)
web3_geth = Web3(Web3.IPCProvider(geth_ipc_path))
Expand Down
5 changes: 2 additions & 3 deletions tests/integration/parity/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
PARITY_2_3_5_FIXTURE = {
'zip': 'parity-235-fixture.zip',
'coinbase': 'dc544d1aa88ff8bbd2f2aec754b1f1e99e1812fd',
'block_hash_revert_no_msg': '0x3244617196b9467687cbab23798c00077954452771d38d05d3b8d484b83c5de5',
'block_hash_revert_with_msg': '0x7d7917231f1a9e816f11ff93842d543c35075a7cd5d75854f28324409910836c',
'block_hash_revert_no_msg': '0x3244617196b9467687cbab23798c00077954452771d38d05d3b8d484b83c5de5', # noqa: E501
'block_hash_revert_with_msg': '0x7d7917231f1a9e816f11ff93842d543c35075a7cd5d75854f28324409910836c', # noqa: E501
'block_hash_with_log': '0x19947203802e02d4659698c5684322ef67c4146fb1f420a6da371116be78047c',
'block_with_txn_hash': '0xc26f5610ddbfd6fbe179110e09af6df06c2998ed0c9c623417480b2c795a6f01',
'emitter_address': '0x4aA591a07989b4F810E2F5cE97e769D60710f168',
Expand Down Expand Up @@ -208,7 +208,6 @@ def txn_filter_params(coinbase):
}



@pytest.fixture(scope="module")
def block_hash_revert_no_msg(parity_fixture_data):
return parity_fixture_data['block_hash_revert_no_msg']
Expand Down
1 change: 0 additions & 1 deletion tests/integration/test_ethereum_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ def revert_contract_address(revert_contract, address_conversion_func):
return address_conversion_func(revert_contract.address)



UNLOCKABLE_PRIVATE_KEY = '0x392f63a79b1ff8774845f3fa69de4a13800a59e7083f5187f1558f0797ad0f01'


Expand Down
19 changes: 16 additions & 3 deletions web3/_utils/module_testing/eth_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,10 +665,23 @@ def test_eth_call_with_0_result(
result = web3.codec.decode_single('uint256', call_result)
assert result == 0

def test_eth_call_revert_with_msg(self, web3: "Web3", revert_contract: "Contract", unlocked_account_dual_type: ChecksumAddress) -> None:
def test_eth_call_revert_with_msg(
self,
web3: "Web3",
revert_contract: "Contract",
unlocked_account_dual_type: ChecksumAddress,
) -> None:
coinbase = web3.eth.coinbase
txn_params = revert_contract._prepare_transaction(fn_name='revertWithMessage', transaction={'from': unlocked_account_dual_type, 'to': revert_contract.address})
foo = revert_contract.functions.revertWithMessage().transact({'from': coinbase, 'to': revert_contract.address, 'gas': 320000})
txn_params = revert_contract._prepare_transaction(
fn_name="revertWithMessage",
transaction={
"from": unlocked_account_dual_type,
"to": revert_contract.address,
},
)
revert_contract.functions.revertWithMessage().transact(
{"from": coinbase, "to": revert_contract.address, "gas": Wei(320000)}
)
call_result = web3.eth.call(txn_params)
assert is_string(call_result)
result = web3.codec.decode_single('bool', call_result)
Expand Down
3 changes: 1 addition & 2 deletions web3/_utils/module_testing/revert_contract.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json


REVERT_CONTRACT_SOURCE = """
pragma solidity ^0.6.1;
Expand All @@ -20,7 +19,7 @@
"""


REVERT_CONTRACT_BYTECODE = "608060405234801561001057600080fd5b50610123806100206000396000f3fe6080604052348015600f57600080fd5b5060043610603c5760003560e01c8063185c38a4146041578063c06a97cb146049578063d67e4b84146051575b600080fd5b60476071565b005b604f60df565b005b605760e4565b604051808215151515815260200191505060405180910390f35b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f46756e6374696f6e20686173206265656e2072657665727465642e000000000081525060200191505060405180910390fd5b600080fd5b6000600190509056fea264697066735822122062c811906544562ea796d11199e2d956938f2a76c2aa3053dc7ab2470d854c0a64736f6c63430006060033"
REVERT_CONTRACT_BYTECODE = "608060405234801561001057600080fd5b50610123806100206000396000f3fe6080604052348015600f57600080fd5b5060043610603c5760003560e01c8063185c38a4146041578063c06a97cb146049578063d67e4b84146051575b600080fd5b60476071565b005b604f60df565b005b605760e4565b604051808215151515815260200191505060405180910390f35b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f46756e6374696f6e20686173206265656e2072657665727465642e000000000081525060200191505060405180910390fd5b600080fd5b6000600190509056fea264697066735822122062c811906544562ea796d11199e2d956938f2a76c2aa3053dc7ab2470d854c0a64736f6c63430006060033" # noqa: E501


REVERT_CONTRACT_RUNTIME_CODE = "6080604052348015600f57600080fd5b5060043610603c5760003560e01c8063185c38a4146041578063c06a97cb146049578063d67e4b84146051575b600080fd5b60476071565b005b604f60df565b005b605760e4565b604051808215151515815260200191505060405180910390f35b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f46756e6374696f6e20686173206265656e2072657665727465642e000000000081525060200191505060405180910390fd5b600080fd5b6000600190509056fea264697066735822122062c811906544562ea796d11199e2d956938f2a76c2aa3053dc7ab2470d854c0a64736f6c63430006060033" # noqa: E501
Expand Down

0 comments on commit 60cccbc

Please sign in to comment.