diff --git a/pyethapp/config.py b/pyethapp/config.py index 2928bbd1..42c3dbf8 100644 --- a/pyethapp/config.py +++ b/pyethapp/config.py @@ -143,6 +143,7 @@ def set_config_param(config, s, strict=True): raise ValueError('Invalid config parameter') d = config for key in keys[:-1]: + key = key.strip() if strict and key not in d: raise KeyError('Unknown config option %s' % param) d = d.setdefault(key, {}) diff --git a/pyethapp/tests/test_rpc_tests.py b/pyethapp/tests/test_rpc_tests.py index 3484f67c..5b02ccc8 100644 --- a/pyethapp/tests/test_rpc_tests.py +++ b/pyethapp/tests/test_rpc_tests.py @@ -1,6 +1,8 @@ import os import pytest -from subprocess import Popen +from subprocess import Popen, PIPE +import time +import re #def test_externally(test_app, tmpdir): @@ -26,7 +28,6 @@ def test_setup(request, tmpdir): rpc_tests_dir = prepare_rpc_tests(tmpdir) test_data = rpc_tests_dir.join('lib/tests/BlockchainTests/bcRPC_API_Test.json') - test_app = Popen([ 'pyethapp', '-d', str(tmpdir), @@ -46,12 +47,36 @@ def fin(): @pytest.mark.skipif(os.getenv('TRAVIS') != None, reason="don't start external test on travis") def test_eth(test_setup): - # The results of the external rpc-tests are not evaluated as: + # Some of the errors of the external rpc-tests are ignored as: # 1) the Whisper protocol is not implemented and its tests fail; # 2) the eth_accounts method should be skipped; # 3) the eth_getFilterLogs fails due to the invalid test data; + ignored_errors = [ + 'eth_accounts PYTHON should return an array with accounts:', + 'eth_getFilterLogs PYTHON should return a list of logs, when asking without defining an address and using toBlock "latest":', + 'eth_getFilterLogs PYTHON should return a list of logs, when asking without defining an address and using toBlock "pending":', + 'eth_getFilterLogs PYTHON should return a list of logs, when filtering with defining an address and using toBlock "latest":', + 'eth_getFilterLogs PYTHON should return a list of logs, when filtering with defining an address and using toBlock "pending":', + 'eth_getFilterLogs PYTHON should return a list of logs, when filtering by topic "0x0000000000000000000000000000000000000000000000000000000000000001":', + 'eth_getFilterLogs PYTHON should return a list of anonymous logs, when filtering by topic "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff":', + 'eth_getFilterLogs PYTHON should return a list of logs, when filtering by topic "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff":', + # The following error is fixed in the PR rpc-tests#9 + 'eth_getTransactionByBlockNumberAndIndex PYTHON should return transactions for the pending block when using "pending" and sending transactions before:', + 'eth_uninstallFilter PYTHON should return a boolean when uninstalling a block filter:'] + (test_app, rpc_tests_dir) = test_setup - tests = Popen(['make', 'test.eth'], cwd=str(rpc_tests_dir)).wait() - assert False, tests.stdout - #FIXME: parse test results and generate report in a pytest compatible format + time.sleep(60) + tests = Popen(['make', 'test.eth'], stdout=PIPE, cwd=str(rpc_tests_dir)) + output = tests.communicate()[0] + rpc_errors = re.finditer(r' (\d+)\)(.+)\n', output) + success = True + err_string = '' + for e in rpc_errors: + if e.groups()[1].strip() in ignored_errors: + err_string += '\nSkipping: ' + e.groups()[1] + else: + err_string += '\nERROR: ' + e.groups()[1] + success = False + assert success, err_string + #FIXME: generate a report in a pytest compatible format