From bc1a2ad080650b3de31fddd3743312ba3d3a9d66 Mon Sep 17 00:00:00 2001 From: Andre Miras Date: Thu, 8 Jun 2017 23:30:35 +0200 Subject: [PATCH] Fixes solidity warnings Two tests updated: - test_console_name_reg_contract() - test_compile_solidity() The warning was: "solc_wrapper is deprecated, ..." --- pyethapp/console_service.py | 2 +- pyethapp/jsonrpc.py | 4 ++-- pyethapp/tests/test_console_service.py | 13 +++++++++---- pyethapp/tests/test_jsonrpc.py | 16 ++++++++++++---- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/pyethapp/console_service.py b/pyethapp/console_service.py index 9a4fc37b..7a890ac3 100644 --- a/pyethapp/console_service.py +++ b/pyethapp/console_service.py @@ -259,7 +259,7 @@ def block_from_rlp(this, rlp_data): return TransientBlock.init_from_rlp(l).to_block() try: - from ethereum._solidity import solc_wrapper + from ethereum.tools._solidity import solc_wrapper except ImportError: solc_wrapper = None pass diff --git a/pyethapp/jsonrpc.py b/pyethapp/jsonrpc.py index 4cede3f7..c5fbd074 100644 --- a/pyethapp/jsonrpc.py +++ b/pyethapp/jsonrpc.py @@ -711,8 +711,8 @@ def compilers(self): except ImportError: pass try: - import ethereum._solidity - s = ethereum._solidity.get_solidity() + import ethereum.tools._solidity + s = ethereum.tools._solidity.get_solidity() if s: self.compilers_['solidity'] = s.compile_rich else: diff --git a/pyethapp/tests/test_console_service.py b/pyethapp/tests/test_console_service.py index ca6b03e1..a61ae1ce 100644 --- a/pyethapp/tests/test_console_service.py +++ b/pyethapp/tests/test_console_service.py @@ -169,14 +169,19 @@ def test_console_name_reg_contract(test_app): } """ - import ethereum.tools._solidity - solidity = ethereum.tools._solidity.get_solidity() + from ethereum.tools import _solidity + solidity = _solidity.get_solidity() if solidity is None: pytest.xfail("solidity not installed, not tested") else: # create the NameReg contract tx_to = b'' - evm_code = solidity.compile(solidity_code) + filepath = None + contract_name = 'NameReg' + compiled = _solidity.compile_code( + solidity_code, + combined='bin,abi') + evm_code = _solidity.solidity_get_contract_data(compiled, filepath, contract_name)['bin'] chainservice = test_app.services.chain chain = test_app.services.chain.chain hc_state = State(chainservice.head_candidate.state_root, chain.env) @@ -200,7 +205,7 @@ def test_console_name_reg_contract(test_app): assert code != '0x' # interact with the NameReg contract - abi = solidity.mk_full_signature(solidity_code) + abi = _solidity.solidity_get_contract_data(compiled, filepath, contract_name)['abi'] namereg = eth.new_contract(abi, creates, sender=sender) register_tx = namereg.register('alice', startgas=90000, gasprice=50 * 10**9) diff --git a/pyethapp/tests/test_jsonrpc.py b/pyethapp/tests/test_jsonrpc.py index f0fb3302..65f1af21 100644 --- a/pyethapp/tests/test_jsonrpc.py +++ b/pyethapp/tests/test_jsonrpc.py @@ -77,10 +77,18 @@ def test_compile_solidity(): with open(path.join(path.dirname(__file__), 'contracts', 'multiply.sol')) as handler: solidity_code = handler.read() - solidity = ethereum._solidity.get_solidity() # pylint: disable=protected-access - - abi = solidity.mk_full_signature(solidity_code) - code = data_encoder(solidity.compile(solidity_code)) + filepath = None + contract_name = 'test' + compiled = _solidity.compile_code( + solidity_code, + combined='bin,abi') + # well it seems we could also access it directly using: + # compiled['test']['abi'] + abi = _solidity.solidity_get_contract_data(compiled, filepath, contract_name)['abi'] + # compiled['test']['bin_hex'] + code = _solidity.solidity_get_contract_data(compiled, filepath, contract_name)['bin_hex'] + # add the "0x" prefix to keep consistency with compileSolidity() + code = "0x" + code info = { 'abiDefinition': abi,