From 60cccbc33450e5b0524773dde6239358e6791e71 Mon Sep 17 00:00:00 2001 From: Marc Garreau Date: Fri, 24 Jul 2020 09:55:46 -0600 Subject: [PATCH] address linting issues --- .../contracts/test_contract_call_interface.py | 4 ---- tests/generate_go_ethereum_fixture.py | 2 +- tests/integration/conftest.py | 8 ++++++-- tests/integration/generate_fixtures/parity.py | 3 ++- tests/integration/parity/conftest.py | 5 ++--- tests/integration/test_ethereum_tester.py | 1 - web3/_utils/module_testing/eth_module.py | 19 ++++++++++++++++--- web3/_utils/module_testing/revert_contract.py | 3 +-- 8 files changed, 28 insertions(+), 17 deletions(-) diff --git a/tests/core/contracts/test_contract_call_interface.py b/tests/core/contracts/test_contract_call_interface.py index ebf1e7c363..af50991f4e 100644 --- a/tests/core/contracts/test_contract_call_interface.py +++ b/tests/core/contracts/test_contract_call_interface.py @@ -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( diff --git a/tests/generate_go_ethereum_fixture.py b/tests/generate_go_ethereum_fixture.py index 4135b8a630..db3cce7696 100644 --- a/tests/generate_go_ethereum_fixture.py +++ b/tests/generate_go_ethereum_fixture.py @@ -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' diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 43650e43b1..a9ddbbd19e 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -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 diff --git a/tests/integration/generate_fixtures/parity.py b/tests/integration/generate_fixtures/parity.py index aa9de11d91..e53ee96064 100644 --- a/tests/integration/generate_fixtures/parity.py +++ b/tests/integration/generate_fixtures/parity.py @@ -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)) diff --git a/tests/integration/parity/conftest.py b/tests/integration/parity/conftest.py index 7fbf8d84f7..c05274f370 100644 --- a/tests/integration/parity/conftest.py +++ b/tests/integration/parity/conftest.py @@ -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', @@ -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'] diff --git a/tests/integration/test_ethereum_tester.py b/tests/integration/test_ethereum_tester.py index d109c6820d..483d23ee55 100644 --- a/tests/integration/test_ethereum_tester.py +++ b/tests/integration/test_ethereum_tester.py @@ -161,7 +161,6 @@ def revert_contract_address(revert_contract, address_conversion_func): return address_conversion_func(revert_contract.address) - UNLOCKABLE_PRIVATE_KEY = '0x392f63a79b1ff8774845f3fa69de4a13800a59e7083f5187f1558f0797ad0f01' diff --git a/web3/_utils/module_testing/eth_module.py b/web3/_utils/module_testing/eth_module.py index 93303f1999..90fa39e13d 100644 --- a/web3/_utils/module_testing/eth_module.py +++ b/web3/_utils/module_testing/eth_module.py @@ -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) diff --git a/web3/_utils/module_testing/revert_contract.py b/web3/_utils/module_testing/revert_contract.py index 0623737cb9..6a7e65ceed 100644 --- a/web3/_utils/module_testing/revert_contract.py +++ b/web3/_utils/module_testing/revert_contract.py @@ -1,6 +1,5 @@ import json - REVERT_CONTRACT_SOURCE = """ pragma solidity ^0.6.1; @@ -20,7 +19,7 @@ """ -REVERT_CONTRACT_BYTECODE = "608060405234801561001057600080fd5b50610123806100206000396000f3fe6080604052348015600f57600080fd5b5060043610603c5760003560e01c8063185c38a4146041578063c06a97cb146049578063d67e4b84146051575b600080fd5b60476071565b005b604f60df565b005b605760e4565b604051808215151515815260200191505060405180910390f35b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f46756e6374696f6e20686173206265656e2072657665727465642e000000000081525060200191505060405180910390fd5b600080fd5b6000600190509056fea264697066735822122062c811906544562ea796d11199e2d956938f2a76c2aa3053dc7ab2470d854c0a64736f6c63430006060033" +REVERT_CONTRACT_BYTECODE = "608060405234801561001057600080fd5b50610123806100206000396000f3fe6080604052348015600f57600080fd5b5060043610603c5760003560e01c8063185c38a4146041578063c06a97cb146049578063d67e4b84146051575b600080fd5b60476071565b005b604f60df565b005b605760e4565b604051808215151515815260200191505060405180910390f35b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f46756e6374696f6e20686173206265656e2072657665727465642e000000000081525060200191505060405180910390fd5b600080fd5b6000600190509056fea264697066735822122062c811906544562ea796d11199e2d956938f2a76c2aa3053dc7ab2470d854c0a64736f6c63430006060033" # noqa: E501 REVERT_CONTRACT_RUNTIME_CODE = "6080604052348015600f57600080fd5b5060043610603c5760003560e01c8063185c38a4146041578063c06a97cb146049578063d67e4b84146051575b600080fd5b60476071565b005b604f60df565b005b605760e4565b604051808215151515815260200191505060405180910390f35b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f46756e6374696f6e20686173206265656e2072657665727465642e000000000081525060200191505060405180910390fd5b600080fd5b6000600190509056fea264697066735822122062c811906544562ea796d11199e2d956938f2a76c2aa3053dc7ab2470d854c0a64736f6c63430006060033" # noqa: E501