diff --git a/.travis.yml b/.travis.yml index 2832910..976c656 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,9 +8,10 @@ env: - TOX_ENV=py34 - TOX_ENV=py35 - TOX_ENV=flake8 -cache: pip +cache: + pip: true install: - - "travis_retry pip install setuptools --upgrade" + - "travis_retry pip install setuptools pip --upgrade" - "travis_retry pip install tox" script: - tox -e $TOX_ENV diff --git a/conftest.py b/conftest.py index ae3a442..c12d34a 100644 --- a/conftest.py +++ b/conftest.py @@ -50,10 +50,9 @@ def hex_accounts(accounts): @pytest.yield_fixture() def rpc_server(): - from testrpc.server import application - from testrpc.testrpc import full_reset + from testrpc.server import get_application - full_reset() + application = get_application() port = get_open_port() diff --git a/requirements-dev.txt b/requirements-dev.txt index f066ef0..15bee0e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,4 @@ pytest==2.9.2 requests==2.10.0 gevent==1.1.2 +rlp==0.4.6 diff --git a/setup.py b/setup.py index 312a85e..39b06df 100755 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ ], entry_points={ 'console_scripts': [ - 'testrpc=testrpc.__main__:main', + 'testrpc-py=testrpc.cli:runserver', ], } ) diff --git a/testrpc/__main__.py b/testrpc/cli.py similarity index 83% rename from testrpc/__main__.py rename to testrpc/cli.py index 0e31cbb..eb988a5 100644 --- a/testrpc/__main__.py +++ b/testrpc/cli.py @@ -14,11 +14,7 @@ accounts, ) -from .server import application -from .testrpc import ( - web3_clientVersion, - evm_reset, -) +from .server import get_application @click.command() @@ -33,11 +29,10 @@ default=8545, type=int, ) -def main(host, port): - - print(web3_clientVersion()) +def runserver(host, port): + application = get_application() - evm_reset() + print(application.rpc_methods.web3_clientVersion()) print("\nAvailable Accounts\n==================") for account in accounts: diff --git a/testrpc/rpc.py b/testrpc/rpc.py new file mode 100755 index 0000000..df8bbb0 --- /dev/null +++ b/testrpc/rpc.py @@ -0,0 +1,225 @@ +import sys +import logging + +from sha3 import sha3_256 + +from ethereum.tester import ( + languages, +) + +from .client import EthTesterClient +from .client.utils import ( + force_bytes, + decode_hex, + encode_number, + encode_32bytes, +) + +from .utils import ( + input_transaction_formatter, + input_filter_params_formatter, + normalize_block_number, +) + + +logger = logging.getLogger(__name__) + + +class RPCMethods(object): + def __init__(self): + self.full_reset() + + def full_reset(self): + self.client = EthTesterClient() + self.reset_rpc_meta() + + def reset_rpc_meta(self): + self.RPC_META = { + 'eth_protocolVersion': 63, + 'eth_syncing': False, + 'eth_mining': True, + 'net_version': 1, + 'net_listening': False, + 'net_peerCount': 0, + 'homestead_block_number': self.client.evm.block.config['HOMESTEAD_FORK_BLKNUM'], + 'dao_fork_block_number': self.client.evm.block.config['DAO_FORK_BLKNUM'], + } + + def rpc_configure(self, key, value): + self.RPC_META[key] = value + + if key == 'homestead_block_number': + self.client.evm.block.config['HOMESTEAD_FORK_BLKNUM'] = value + elif key == 'dao_fork_block_number': + self.client.evm.block.config['DAO_FORK_BLKNUM'] = value + + # + # Snapshot and Reset + # + def evm_reset(self): + self.client.reset_evm() + return True + + def evm_snapshot(self): + snapshot_idx = self.client.snapshot_evm() + return encode_number(snapshot_idx) + + def evm_revert(self, snapshot_idx=None): + try: + self.client.revert_evm(snapshot_idx) + except ValueError: + return False + else: + return True + + def evm_mine(self): + self.client.mine_block() + + # + # eth_ Functions + # + def eth_coinbase(self): + logger.info('eth_coinbase') + return self.client.get_coinbase() + + def eth_gasPrice(self): + logger.info('eth_gasPrice') + return encode_number(self.client.get_gas_price()) + + def eth_blockNumber(self): + logger.info('eth_blockNumber') + return encode_number(self.client.get_block_number()) + + def eth_sendTransaction(self, transaction): + formatted_transaction = input_transaction_formatter(transaction) + return self.client.send_transaction(**formatted_transaction) + + def eth_estimateGas(self, transaction, block_number="latest"): + formatted_transaction = input_transaction_formatter(transaction) + return self.client.estimate_gas(**formatted_transaction) + + def eth_sendRawTransaction(self, raw_tx): + return self.client.send_raw_transaction(raw_tx) + + def eth_call(self, transaction, block_number="latest"): + formatted_transaction = input_transaction_formatter(transaction) + return self.client.call(**formatted_transaction) + + def eth_accounts(self): + return self.client.get_accounts() + + def eth_getCompilers(self): + return languages.keys() + + def eth_compileSolidity(self, code): + # TODO: convert to python-solidity lib once it exists + raise NotImplementedError("This has not yet been implemented") + + def eth_getCode(self, address, block_number="latest"): + return self.client.get_code(address, normalize_block_number(block_number)) + + def eth_getBalance(self, address, block_number="latest"): + return self.client.get_balance(address, normalize_block_number(block_number)) + + def eth_getTransactionCount(self, address, block_number="latest"): + return encode_number(self.client.get_transaction_count( + address, + normalize_block_number(block_number), + )) + + def eth_getTransactionByHash(self, tx_hash): + try: + return self.client.get_transaction_by_hash(tx_hash) + except ValueError: + return None + + def eth_getBlockByHash(self, block_hash, full_tx=True): + return self.client.get_block_by_hash(block_hash, full_tx) + + def eth_getBlockByNumber(self, block_number, full_tx=True): + return self.client.get_block_by_number(normalize_block_number(block_number), full_tx) + + def eth_getTransactionReceipt(self, tx_hash): + try: + return self.client.get_transaction_receipt(tx_hash) + except ValueError: + return None + + def eth_newBlockFilter(self, *args, **kwargs): + # TODO: convert to tester_client once filters implemented + raise NotImplementedError("This has not yet been implemented") + + def eth_newPendingTransactionFilter(self, *args, **kwargs): + # TODO: convert to tester_client once filters implemented + raise NotImplementedError("This has not yet been implemented") + + def eth_newFilter(self, filter_params): + formatted_filter_params = input_filter_params_formatter(filter_params) + return self.client.new_filter(**formatted_filter_params) + + def eth_getFilterChanges(self, filter_id): + return self.client.get_filter_changes(filter_id) + + def eth_getFilterLogs(self, filter_id): + return self.client.get_filter_logs(filter_id) + + def eth_uninstallFilter(self, filter_id): + return self.client.uninstall_filter(filter_id) + + def eth_protocolVersion(self): + return self.RPC_META['eth_protocolVersion'] + + def eth_syncing(self): + return self.RPC_META['eth_syncing'] + + def eth_mining(self): + return self.RPC_META['eth_mining'] + + def web3_sha3(self, value, encoding='hex'): + logger.info('web3_sha3') + if encoding == 'hex': + value = decode_hex(value) + else: + value = force_bytes(value) + return encode_32bytes(sha3_256(value).digest()) + + def web3_clientVersion(self): + from testrpc import __version__ + return "TestRPC/" + __version__ + "/{platform}/python{v.major}.{v.minor}.{v.micro}".format( + v=sys.version_info, + platform=sys.platform, + ) + + # + # net_ API + # + def net_version(self): + return self.RPC_META['net_version'] + + def net_listening(self): + return self.RPC_META['net_listening'] + + def net_peerCount(self): + return self.RPC_META['net_peerCount'] + + # + # personal_ API + # + def personal_listAccounts(self): + return self.eth_accounts() + + def personal_importRawKey(self, private_key, passphrase): + return self.client.import_raw_key(private_key, passphrase) + + def personal_lockAccount(self, address): + return self.client.lock_account(address) + + def personal_newAccount(self, passphrase=None): + return self.client.new_account(passphrase) + + def personal_unlockAccount(self, address, passphrase, duration=None): + return self.client.unlock_account(address, passphrase, duration) + + def personal_signAndSendTransaction(self, transaction, passphrase): + formatted_transaction = input_transaction_formatter(transaction) + return self.client.send_and_sign_transaction(passphrase, **formatted_transaction) diff --git a/testrpc/server.py b/testrpc/server.py index 98b4d0b..3b5a881 100644 --- a/testrpc/server.py +++ b/testrpc/server.py @@ -7,7 +7,7 @@ from jsonrpc import JSONRPCResponseManager, dispatcher -from . import testrpc +from .rpc import RPCMethods from .client.utils import ( force_obj_to_text, ) @@ -18,88 +18,88 @@ "Access-Control-Allow-Origin": "*", } -# When calling server.register_function, first wrap the function in a mutex. -# This has the effect of serializing all RPC calls. Although we use a -# multithreaded HTTP server, the EVM itself is not thread-safe, so we must take -# care when interacting with it. -evm_lock = Lock() - -def with_lock(rpc_fn): - @functools.wraps(rpc_fn) - def inner(*args, **kwargs): - evm_lock.acquire() - try: - return rpc_fn(*args, **kwargs) - finally: - evm_lock.release() - - return inner - - -def add_method_with_lock(rpc_fn, *args, **kwargs): - rpc_fn_with_lock = with_lock(rpc_fn) - return dispatcher.add_method(rpc_fn_with_lock, *args, **kwargs) - - -add_method_with_lock(testrpc.eth_coinbase, 'eth_coinbase') -add_method_with_lock(testrpc.eth_accounts, 'eth_accounts') -add_method_with_lock(testrpc.eth_gasPrice, 'eth_gasPrice') -add_method_with_lock(testrpc.eth_blockNumber, 'eth_blockNumber') -add_method_with_lock(testrpc.eth_estimateGas, 'eth_estimateGas') -add_method_with_lock(testrpc.eth_call, 'eth_call') -add_method_with_lock(testrpc.eth_sendTransaction, 'eth_sendTransaction') -add_method_with_lock(testrpc.eth_sendRawTransaction, 'eth_sendRawTransaction') -add_method_with_lock(testrpc.eth_getCompilers, 'eth_getCompilers') -add_method_with_lock(testrpc.eth_compileSolidity, 'eth_compileSolidity') -add_method_with_lock(testrpc.eth_getCode, 'eth_getCode') -add_method_with_lock(testrpc.eth_getBalance, 'eth_getBalance') -add_method_with_lock(testrpc.eth_getTransactionCount, 'eth_getTransactionCount') -add_method_with_lock(testrpc.eth_getTransactionByHash, 'eth_getTransactionByHash') -add_method_with_lock(testrpc.eth_getTransactionReceipt, 'eth_getTransactionReceipt') -add_method_with_lock(testrpc.eth_getBlockByHash, 'eth_getBlockByHash') -add_method_with_lock(testrpc.eth_getBlockByNumber, 'eth_getBlockByNumber') -add_method_with_lock(testrpc.eth_newBlockFilter, 'eth_newBlockFilter') -add_method_with_lock(testrpc.eth_newPendingTransactionFilter, - 'eth_newPendingTransactionFilter') -add_method_with_lock(testrpc.eth_newFilter, 'eth_newFilter') -add_method_with_lock(testrpc.eth_getFilterChanges, 'eth_getFilterChanges') -add_method_with_lock(testrpc.eth_getFilterLogs, 'eth_getFilterLogs') -add_method_with_lock(testrpc.eth_uninstallFilter, 'eth_uninstallFilter') -add_method_with_lock(testrpc.eth_protocolVersion, 'eth_protocolVersion') -add_method_with_lock(testrpc.eth_syncing, 'eth_syncing') -add_method_with_lock(testrpc.eth_mining, 'eth_mining') -add_method_with_lock(testrpc.web3_sha3, 'web3_sha3') -add_method_with_lock(testrpc.web3_clientVersion, 'web3_clientVersion') -add_method_with_lock(testrpc.net_version, 'net_version') -add_method_with_lock(testrpc.net_listening, 'net_listening') -add_method_with_lock(testrpc.net_peerCount, 'net_peerCount') -add_method_with_lock(testrpc.evm_reset, 'evm_reset') -add_method_with_lock(testrpc.evm_snapshot, 'evm_snapshot') -add_method_with_lock(testrpc.evm_revert, 'evm_revert') -add_method_with_lock(testrpc.evm_mine, 'evm_mine') -add_method_with_lock(testrpc.rpc_configure, 'rpc_configure') -add_method_with_lock(testrpc.personal_importRawKey, 'personal_importRawKey') -add_method_with_lock(testrpc.personal_listAccounts, 'personal_listAccounts') -add_method_with_lock(testrpc.personal_lockAccount, 'personal_lockAccount') -add_method_with_lock(testrpc.personal_newAccount, 'personal_newAccount') -add_method_with_lock(testrpc.personal_unlockAccount, 'personal_unlockAccount') -add_method_with_lock(testrpc.personal_signAndSendTransaction, - 'personal_signAndSendTransaction') - - -@Request.application -def application(request): - response = JSONRPCResponseManager.handle( - request.data, - dispatcher, - ) - response = Response( - json.dumps(force_obj_to_text(response.data, True)), - headers=RESPONSE_HEADERS, - mimetype='application/json', - ) - return response - - -application.testrpc = testrpc +def get_application(): + # When calling server.register_function, first wrap the function in a mutex. + # This has the effect of serializing all RPC calls. Although we use a + # multithreaded HTTP server, the EVM itself is not thread-safe, so we must take + # care when interacting with it. + rpc_methods = RPCMethods() + evm_lock = Lock() + + def with_lock(rpc_fn): + @functools.wraps(rpc_fn) + def inner(*args, **kwargs): + evm_lock.acquire() + try: + return rpc_fn(*args, **kwargs) + finally: + evm_lock.release() + + return inner + + def add_method_with_lock(rpc_fn, *args, **kwargs): + rpc_fn_with_lock = with_lock(rpc_fn) + return dispatcher.add_method(rpc_fn_with_lock, *args, **kwargs) + + add_method_with_lock(rpc_methods.eth_coinbase, 'eth_coinbase') + add_method_with_lock(rpc_methods.eth_accounts, 'eth_accounts') + add_method_with_lock(rpc_methods.eth_gasPrice, 'eth_gasPrice') + add_method_with_lock(rpc_methods.eth_blockNumber, 'eth_blockNumber') + add_method_with_lock(rpc_methods.eth_estimateGas, 'eth_estimateGas') + add_method_with_lock(rpc_methods.eth_call, 'eth_call') + add_method_with_lock(rpc_methods.eth_sendTransaction, 'eth_sendTransaction') + add_method_with_lock(rpc_methods.eth_sendRawTransaction, 'eth_sendRawTransaction') + add_method_with_lock(rpc_methods.eth_getCompilers, 'eth_getCompilers') + add_method_with_lock(rpc_methods.eth_compileSolidity, 'eth_compileSolidity') + add_method_with_lock(rpc_methods.eth_getCode, 'eth_getCode') + add_method_with_lock(rpc_methods.eth_getBalance, 'eth_getBalance') + add_method_with_lock(rpc_methods.eth_getTransactionCount, 'eth_getTransactionCount') + add_method_with_lock(rpc_methods.eth_getTransactionByHash, 'eth_getTransactionByHash') + add_method_with_lock(rpc_methods.eth_getTransactionReceipt, 'eth_getTransactionReceipt') + add_method_with_lock(rpc_methods.eth_getBlockByHash, 'eth_getBlockByHash') + add_method_with_lock(rpc_methods.eth_getBlockByNumber, 'eth_getBlockByNumber') + add_method_with_lock(rpc_methods.eth_newBlockFilter, 'eth_newBlockFilter') + add_method_with_lock(rpc_methods.eth_newPendingTransactionFilter, + 'eth_newPendingTransactionFilter') + add_method_with_lock(rpc_methods.eth_newFilter, 'eth_newFilter') + add_method_with_lock(rpc_methods.eth_getFilterChanges, 'eth_getFilterChanges') + add_method_with_lock(rpc_methods.eth_getFilterLogs, 'eth_getFilterLogs') + add_method_with_lock(rpc_methods.eth_uninstallFilter, 'eth_uninstallFilter') + add_method_with_lock(rpc_methods.eth_protocolVersion, 'eth_protocolVersion') + add_method_with_lock(rpc_methods.eth_syncing, 'eth_syncing') + add_method_with_lock(rpc_methods.eth_mining, 'eth_mining') + add_method_with_lock(rpc_methods.web3_sha3, 'web3_sha3') + add_method_with_lock(rpc_methods.web3_clientVersion, 'web3_clientVersion') + add_method_with_lock(rpc_methods.net_version, 'net_version') + add_method_with_lock(rpc_methods.net_listening, 'net_listening') + add_method_with_lock(rpc_methods.net_peerCount, 'net_peerCount') + add_method_with_lock(rpc_methods.evm_reset, 'evm_reset') + add_method_with_lock(rpc_methods.evm_snapshot, 'evm_snapshot') + add_method_with_lock(rpc_methods.evm_revert, 'evm_revert') + add_method_with_lock(rpc_methods.evm_mine, 'evm_mine') + add_method_with_lock(rpc_methods.rpc_configure, 'rpc_configure') + add_method_with_lock(rpc_methods.personal_importRawKey, 'personal_importRawKey') + add_method_with_lock(rpc_methods.personal_listAccounts, 'personal_listAccounts') + add_method_with_lock(rpc_methods.personal_lockAccount, 'personal_lockAccount') + add_method_with_lock(rpc_methods.personal_newAccount, 'personal_newAccount') + add_method_with_lock(rpc_methods.personal_unlockAccount, 'personal_unlockAccount') + add_method_with_lock(rpc_methods.personal_signAndSendTransaction, + 'personal_signAndSendTransaction') + + @Request.application + def application(request): + response = JSONRPCResponseManager.handle( + request.data, + dispatcher, + ) + response = Response( + json.dumps(force_obj_to_text(response.data, True)), + headers=RESPONSE_HEADERS, + mimetype='application/json', + ) + return response + + application.rpc_methods = rpc_methods + + return application diff --git a/testrpc/testrpc.py b/testrpc/testrpc.py deleted file mode 100755 index 5121570..0000000 --- a/testrpc/testrpc.py +++ /dev/null @@ -1,272 +0,0 @@ -import sys -import pkg_resources -import logging - -from sha3 import sha3_256 - -from ethereum.tester import ( - languages, -) - -from .client import EthTesterClient -from .client.utils import ( - force_bytes, - decode_hex, - encode_number, - encode_32bytes, -) - -from .utils import ( - input_transaction_formatter, - input_filter_params_formatter, - normalize_block_number, -) - - -__version__ = pkg_resources.get_distribution("eth-testrpc").version - - -logger = logging.getLogger(__name__) - - -# -# Global Client -# -tester_client = EthTesterClient() - - -def full_reset(): - global tester_client - tester_client = EthTesterClient() - - -# -# Snapshot and Reset -# -def evm_reset(): - tester_client.reset_evm() - return True - - -def evm_snapshot(): - snapshot_idx = tester_client.snapshot_evm() - return encode_number(snapshot_idx) - - -def evm_revert(snapshot_idx=None): - try: - tester_client.revert_evm(snapshot_idx) - except ValueError: - return False - else: - return True - - -def evm_mine(): - tester_client.mine_block() - - -# -# Web3 Functions -# -def eth_coinbase(): - logger.info('eth_coinbase') - return tester_client.get_coinbase() - - -def eth_gasPrice(): - logger.info('eth_gasPrice') - return encode_number(tester_client.get_gas_price()) - - -def eth_blockNumber(): - logger.info('eth_blockNumber') - return encode_number(tester_client.get_block_number()) - - -def eth_sendTransaction(transaction): - formatted_transaction = input_transaction_formatter(transaction) - return tester_client.send_transaction(**formatted_transaction) - - -def eth_estimateGas(transaction, block_number="latest"): - formatted_transaction = input_transaction_formatter(transaction) - return tester_client.estimate_gas(**formatted_transaction) - - -def eth_sendRawTransaction(raw_tx): - return tester_client.send_raw_transaction(raw_tx) - - -def eth_call(transaction, block_number="latest"): - formatted_transaction = input_transaction_formatter(transaction) - return tester_client.call(**formatted_transaction) - - -def eth_accounts(): - return tester_client.get_accounts() - - -def eth_getCompilers(): - return languages.keys() - - -def eth_compileSolidity(code): - # TODO: convert to python-solidity lib once it exists - raise NotImplementedError("This has not yet been implemented") - - -def eth_getCode(address, block_number="latest"): - return tester_client.get_code(address, normalize_block_number(block_number)) - - -def eth_getBalance(address, block_number="latest"): - return tester_client.get_balance(address, normalize_block_number(block_number)) - - -def eth_getTransactionCount(address, block_number="latest"): - return encode_number(tester_client.get_transaction_count( - address, - normalize_block_number(block_number), - )) - - -def eth_getTransactionByHash(tx_hash): - try: - return tester_client.get_transaction_by_hash(tx_hash) - except ValueError: - return None - - -def eth_getBlockByHash(block_hash, full_tx=True): - return tester_client.get_block_by_hash(block_hash, full_tx) - - -def eth_getBlockByNumber(block_number, full_tx=True): - return tester_client.get_block_by_number(normalize_block_number(block_number), full_tx) - - -def eth_getTransactionReceipt(tx_hash): - try: - return tester_client.get_transaction_receipt(tx_hash) - except ValueError: - return None - - -def eth_newBlockFilter(*args, **kwargs): - # TODO: convert to tester_client once filters implemented - raise NotImplementedError("This has not yet been implemented") - - -def eth_newPendingTransactionFilter(*args, **kwargs): - # TODO: convert to tester_client once filters implemented - raise NotImplementedError("This has not yet been implemented") - - -FILTER_KWARGS_MAP = { - 'fromBlock': 'from_block', - 'toBlock': 'to_block', -} - - -def eth_newFilter(filter_params): - formatted_filter_params = input_filter_params_formatter(filter_params) - return tester_client.new_filter(**formatted_filter_params) - - -def eth_getFilterChanges(filter_id): - return tester_client.get_filter_changes(filter_id) - - -def eth_getFilterLogs(filter_id): - return tester_client.get_filter_logs(filter_id) - - -def eth_uninstallFilter(filter_id): - return tester_client.uninstall_filter(filter_id) - - -RPC_META = { - 'eth_protocolVersion': 63, - 'eth_syncing': False, - 'eth_mining': True, - 'net_version': 1, - 'net_listening': False, - 'net_peerCount': 0, - 'homestead_block_number': tester_client.evm.block.config['HOMESTEAD_FORK_BLKNUM'], - 'dao_fork_block_number': tester_client.evm.block.config['DAO_FORK_BLKNUM'], -} - - -def rpc_configure(key, value): - RPC_META[key] = value - - if key == 'homestead_block_number': - tester_client.evm.block.config['HOMESTEAD_FORK_BLKNUM'] = value - elif key == 'dao_fork_block_number': - tester_client.evm.block.config['DAO_FORK_BLKNUM'] = value - - -def eth_protocolVersion(): - return RPC_META['eth_protocolVersion'] - - -def eth_syncing(): - return RPC_META['eth_syncing'] - - -def eth_mining(): - return RPC_META['eth_mining'] - - -def web3_sha3(value, encoding='hex'): - logger.info('web3_sha3') - if encoding == 'hex': - value = decode_hex(value) - else: - value = force_bytes(value) - return encode_32bytes(sha3_256(value).digest()) - - -def web3_clientVersion(): - return "TestRPC/" + __version__ + "/{platform}/python{v.major}.{v.minor}.{v.micro}".format( - v=sys.version_info, - platform=sys.platform, - ) - - -def net_version(): - return RPC_META['net_version'] - - -def net_listening(): - return RPC_META['net_listening'] - - -def net_peerCount(): - return RPC_META['net_peerCount'] - - -def personal_listAccounts(): - return eth_accounts() - - -def personal_importRawKey(private_key, passphrase): - return tester_client.import_raw_key(private_key, passphrase) - - -def personal_lockAccount(address): - return tester_client.lock_account(address) - - -def personal_newAccount(passphrase=None): - return tester_client.new_account(passphrase) - - -def personal_unlockAccount(address, passphrase, duration=None): - return tester_client.unlock_account(address, passphrase, duration) - - -def personal_signAndSendTransaction(transaction, passphrase): - formatted_transaction = input_transaction_formatter(transaction) - return tester_client.send_and_sign_transaction(passphrase, **formatted_transaction) diff --git a/tests/endpoints/test_evm_configure.py b/tests/endpoints/test_evm_configure.py index b92c7a5..0b0ef88 100644 --- a/tests/endpoints/test_evm_configure.py +++ b/tests/endpoints/test_evm_configure.py @@ -1,5 +1,5 @@ def test_homestead_fork_block_number(rpc_client): - tester_client = rpc_client.server.application.testrpc.tester_client + tester_client = rpc_client.server.application.rpc_methods.client assert tester_client.evm.block.config['HOMESTEAD_FORK_BLKNUM'] == 0 rpc_client('rpc_configure', ['homestead_block_number', 10]) @@ -9,7 +9,7 @@ def test_homestead_fork_block_number(rpc_client): def test_dao_fork_block_number(rpc_client): - tester_client = rpc_client.server.application.testrpc.tester_client + tester_client = rpc_client.server.application.rpc_methods.client assert tester_client.evm.block.config['DAO_FORK_BLKNUM'] == 0 rpc_client('rpc_configure', ['dao_fork_block_number', 10]) diff --git a/tests/server/test_server_running.py b/tests/server/test_server_running.py index d80e4e0..dd18e52 100644 --- a/tests/server/test_server_running.py +++ b/tests/server/test_server_running.py @@ -5,11 +5,8 @@ from click.testing import CliRunner -from testrpc.testrpc import ( - web3_clientVersion, -) - -from testrpc.__main__ import main +from testrpc.cli import runserver +from testrpc.rpc import RPCMethods def get_open_port(): @@ -35,8 +32,8 @@ def kill_it(): gevent.spawn(kill_it) - result = runner.invoke(main, ['--port', str(port)]) + result = runner.invoke(runserver, ['--port', str(port)]) assert result.exit_code == 0 assert str(port) in result.output - assert web3_clientVersion() in result.output + assert RPCMethods().web3_clientVersion() in result.output