Created
May 6, 2017 01:55
Star
You must be signed in to star a gist
state_revamp_with_pv62 test failures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
===================================================================================================== FAILURES ====================================================================================================== | |
___________________________________________________________________________________________________ test_transfer ___________________________________________________________________________________________________ | |
db = <ethereum.db._EphemDB object at 0x7fd4157b89d0> | |
def test_transfer(db): | |
> k, v, k2, v2 = accounts() | |
ethereum/tests/test_chain.py:100: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
@pytest.fixture(scope="module") | |
def accounts(): | |
> k = sha3(b'cow') | |
E NameError: global name 'sha3' is not defined | |
ethereum/tests/test_chain.py:38: NameError | |
________________________________________________________________________________________________ test_alloc_too_big _________________________________________________________________________________________________ | |
db = <ethereum.db._EphemDB object at 0x7fd4157ba850> | |
def test_alloc_too_big(db): | |
> k, v, k2, v2 = accounts() | |
ethereum/tests/test_chain.py:112: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
@pytest.fixture(scope="module") | |
def accounts(): | |
> k = sha3(b'cow') | |
E NameError: global name 'sha3' is not defined | |
ethereum/tests/test_chain.py:38: NameError | |
_______________________________________________________________________________________________ test_failing_transfer _______________________________________________________________________________________________ | |
db = <ethereum.db._EphemDB object at 0x7fd41625be10> | |
def test_failing_transfer(db): | |
> k, v, k2, v2 = accounts() | |
ethereum/tests/test_chain.py:120: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
@pytest.fixture(scope="module") | |
def accounts(): | |
> k = sha3(b'cow') | |
E NameError: global name 'sha3' is not defined | |
ethereum/tests/test_chain.py:38: NameError | |
__________________________________________________________________________________________________ test_mine_block __________________________________________________________________________________________________ | |
db = <ethereum.db._EphemDB object at 0x7fd41625b650> | |
def test_mine_block(db): | |
> k, v, k2, v2 = accounts() | |
ethereum/tests/test_chain.py:133: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
@pytest.fixture(scope="module") | |
def accounts(): | |
> k = sha3(b'cow') | |
E NameError: global name 'sha3' is not defined | |
ethereum/tests/test_chain.py:38: NameError | |
______________________________________________________________________________ test_block_serialization_with_transaction_empty_genesis ______________________________________________________________________________ | |
db = <ethereum.db._EphemDB object at 0x7fd41625b610> | |
def test_block_serialization_with_transaction_empty_genesis(db): | |
> k, v, k2, v2 = accounts() | |
ethereum/tests/test_chain.py:148: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
@pytest.fixture(scope="module") | |
def accounts(): | |
> k = sha3(b'cow') | |
E NameError: global name 'sha3' is not defined | |
ethereum/tests/test_chain.py:38: NameError | |
_________________________________________________________________________________________ test_mine_block_with_transaction __________________________________________________________________________________________ | |
db = <ethereum.db._EphemDB object at 0x7fd4162631d0> | |
def test_mine_block_with_transaction(db): | |
> k, v, k2, v2 = accounts() | |
ethereum/tests/test_chain.py:157: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
@pytest.fixture(scope="module") | |
def accounts(): | |
> k = sha3(b'cow') | |
E NameError: global name 'sha3' is not defined | |
ethereum/tests/test_chain.py:38: NameError | |
_________________________________________________________________________________________ test_mine_block_with_transaction2 _________________________________________________________________________________________ | |
db = <ethereum.db._EphemDB object at 0x7fd4162637d0> | |
def test_mine_block_with_transaction2(db): | |
> k, v, k2, v2 = accounts() | |
ethereum/tests/test_chain.py:169: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
@pytest.fixture(scope="module") | |
def accounts(): | |
> k = sha3(b'cow') | |
E NameError: global name 'sha3' is not defined | |
ethereum/tests/test_chain.py:38: NameError | |
_________________________________________________________________________________________ test_mine_block_with_transaction3 _________________________________________________________________________________________ | |
db = <ethereum.db._EphemDB object at 0x7fd416263750> | |
def test_mine_block_with_transaction3(db): | |
> k, v, k2, v2 = accounts() | |
ethereum/tests/test_chain.py:183: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
@pytest.fixture(scope="module") | |
def accounts(): | |
> k = sha3(b'cow') | |
E NameError: global name 'sha3' is not defined | |
ethereum/tests/test_chain.py:38: NameError | |
_________________________________________________________________________________________________ test_transaction __________________________________________________________________________________________________ | |
db = <ethereum.db._EphemDB object at 0x7fd4162630d0> | |
def test_transaction(db): | |
> k, v, k2, v2 = accounts() | |
ethereum/tests/test_chain.py:193: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
@pytest.fixture(scope="module") | |
def accounts(): | |
> k = sha3(b'cow') | |
E NameError: global name 'sha3' is not defined | |
ethereum/tests/test_chain.py:38: NameError | |
__________________________________________________________________________________________ test_transaction_serialization ___________________________________________________________________________________________ | |
def test_transaction_serialization(): | |
> k, v, k2, v2 = accounts() | |
ethereum/tests/test_chain.py:204: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
@pytest.fixture(scope="module") | |
def accounts(): | |
> k = sha3(b'cow') | |
E NameError: global name 'sha3' is not defined | |
ethereum/tests/test_chain.py:38: NameError | |
_____________________________________________________________________________________________ test_invalid_transaction ______________________________________________________________________________________________ | |
db = <ethereum.db._EphemDB object at 0x7fd41624e650> | |
def test_invalid_transaction(db): | |
> k, v, k2, v2 = accounts() | |
ethereum/tests/test_chain.py:212: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
@pytest.fixture(scope="module") | |
def accounts(): | |
> k = sha3(b'cow') | |
E NameError: global name 'sha3' is not defined | |
ethereum/tests/test_chain.py:38: NameError | |
________________________________________________________________________________________________ test_genesis_chain _________________________________________________________________________________________________ | |
db = <ethereum.db._EphemDB object at 0x7fd4162491d0> | |
def test_genesis_chain(db): | |
> k, v, k2, v2 = accounts() | |
ethereum/tests/test_chain.py:230: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
@pytest.fixture(scope="module") | |
def accounts(): | |
> k = sha3(b'cow') | |
E NameError: global name 'sha3' is not defined | |
ethereum/tests/test_chain.py:38: NameError | |
_________________________________________________________________________________________________ test_simple_chain _________________________________________________________________________________________________ | |
db = <ethereum.db._EphemDB object at 0x7fd416249490> | |
def test_simple_chain(db): | |
> k, v, k2, v2 = accounts() | |
ethereum/tests/test_chain.py:246: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
@pytest.fixture(scope="module") | |
def accounts(): | |
> k = sha3(b'cow') | |
E NameError: global name 'sha3' is not defined | |
ethereum/tests/test_chain.py:38: NameError | |
________________________________________________________________________________________________ test_add_side_chain ________________________________________________________________________________________________ | |
db = <ethereum.db._EphemDB object at 0x7fd416249d50>, alt_db = <ethereum.db._EphemDB object at 0x7fd416249d90> | |
def test_add_side_chain(db, alt_db): | |
"""" | |
Local: L0, L1, L2 | |
add | |
Remote: R0, R1 | |
""" | |
> k, v, k2, v2 = accounts() | |
ethereum/tests/test_chain.py:275: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
@pytest.fixture(scope="module") | |
def accounts(): | |
> k = sha3(b'cow') | |
E NameError: global name 'sha3' is not defined | |
ethereum/tests/test_chain.py:38: NameError | |
____________________________________________________________________________________________ test_add_longer_side_chain _____________________________________________________________________________________________ | |
db = <ethereum.db._EphemDB object at 0x7fd41624e690>, alt_db = <ethereum.db._EphemDB object at 0x7fd41624e790> | |
def test_add_longer_side_chain(db, alt_db): | |
"""" | |
Local: L0, L1, L2 | |
Remote: R0, R1, R2, R3 | |
""" | |
> k, v, k2, v2 = accounts() | |
ethereum/tests/test_chain.py:304: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
@pytest.fixture(scope="module") | |
def accounts(): | |
> k = sha3(b'cow') | |
E NameError: global name 'sha3' is not defined | |
ethereum/tests/test_chain.py:38: NameError | |
________________________________________________________________________________________________ test_reward_uncles _________________________________________________________________________________________________ | |
db = <ethereum.db._EphemDB object at 0x7fd41624ea50> | |
def test_reward_uncles(db): | |
""" | |
B0 B1 B2 | |
B0 Uncle | |
We raise the block's coinbase account by Rb, the block reward, | |
and also add uncle and nephew rewards | |
""" | |
> k, v, k2, v2 = accounts() | |
ethereum/tests/test_chain.py:336: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
@pytest.fixture(scope="module") | |
def accounts(): | |
> k = sha3(b'cow') | |
E NameError: global name 'sha3' is not defined | |
ethereum/tests/test_chain.py:38: NameError | |
_________________________________________________________________________ test_key[fixtures/KeyStoreTests/basic_tests.json-test2-testdata2] _________________________________________________________________________ | |
filename = 'fixtures/KeyStoreTests/basic_tests.json', testname = 'test2' | |
testdata = {'json': {'crypto': {'cipher': 'aes-128-ctr', 'cipherparams': {'iv': '83dbcc02d8ccb40e466191a123791e0e'}, 'ciphertext'... 'version': 3}, 'password': 'testpassword', 'priv': '7a28b5ba57c53603b0b07b56bba752f7784bf506fa95edc395f5cf6c7514fe9d'} | |
def test_key(filename, testname, testdata,): | |
logger.debug('running test:%r in %r' % (testname, filename)) | |
assert keys.check_keystore_json(testdata["json"]) | |
> privkey = keys.decode_keystore_json(testdata["json"], testdata["password"]) | |
ethereum/tests/test_keys.py:12: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
jsondata = {'crypto': {'cipher': 'aes-128-ctr', 'cipherparams': {'iv': '83dbcc02d8ccb40e466191a123791e0e'}, 'ciphertext': 'd172bf...6ef8358534d458fffccd4e6ad2fbde479c', 'kdf': 'scrypt', ...}, 'id': '3198bc9c-6672-5ab3-d995-4942343ae5b6', 'version': 3} | |
pw = 'testpassword' | |
def decode_keystore_json(jsondata, pw): | |
# Get KDF function and parameters | |
if "crypto" in jsondata: | |
cryptdata = jsondata["crypto"] | |
elif "Crypto" in jsondata: | |
cryptdata = jsondata["Crypto"] | |
else: | |
raise Exception("JSON data must contain \"crypto\" object") | |
kdfparams = cryptdata["kdfparams"] | |
kdf = cryptdata["kdf"] | |
if cryptdata["kdf"] not in kdfs: | |
> raise Exception("Hash algo %s not supported" % kdf) | |
E Exception: Hash algo scrypt not supported | |
ethereum/keys.py:192: Exception | |
______________________________________________________________ test_state[fixtures/StateTests/stPreCompiledContracts.json-CallRipemd160_5-testdata643] ______________________________________________________________ | |
filename = 'fixtures/StateTests/stPreCompiledContracts.json', testname = 'CallRipemd160_5' | |
testdata = {'env': {'currentCoinbase': '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba', 'currentDifficulty': '0x0100', 'currentGasLimi...e5edbc8e2a8697c15331677e6ebf0b': {'balance': '0x0de0b6b3a742c37c', 'code': '0x', 'nonce': '0x01', 'storage': {}}}, ...} | |
def test_state(filename, testname, testdata): | |
logger.debug('running test:%r in %r' % (testname, filename)) | |
> testutils.check_state_test(testutils.fixture_to_bytes(testdata)) | |
ethereum/tests/test_state.py:16: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
ethereum/testutils.py:51: in <lambda> | |
check_state_test = lambda params: run_state_test(params, VERIFY) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
params = {'env': {'currentCoinbase': '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba', 'currentDifficulty': '0x0100', 'currentGasLimi...e5edbc8e2a8697c15331677e6ebf0b': {'balance': '0x0de0b6b3a742c37c', 'code': '0x', 'nonce': '0x01', 'storage': {}}}, ...} | |
mode = 2 | |
def run_state_test(params, mode): | |
pre = params['pre'] | |
exek = params['transaction'] | |
env = params['env'] | |
assert set(env.keys()) == set(['currentGasLimit', 'currentTimestamp', | |
'previousHash', 'currentCoinbase', | |
'currentDifficulty', 'currentNumber']) | |
assert len(env['currentCoinbase']) == 40 | |
konfig = copy.deepcopy(default_config) | |
# konfig['HOMESTEAD_FORK_BLKNUM'] = 1000000 | |
state = State(env=Env(db, konfig), | |
prev_headers=[mk_fake_header(i) for i in range(parse_int_or_hex(env['currentNumber']) -1, max(-1, parse_int_or_hex(env['currentNumber']) -257), -1)], | |
block_number=parse_int_or_hex(env['currentNumber']), | |
block_coinbase=utils.normalize_address(env['currentCoinbase']), | |
timestamp=parse_int_or_hex(env['currentTimestamp']), | |
gas_limit=parse_int_or_hex(env['currentGasLimit']), | |
block_difficulty=parse_int_or_hex(env['currentDifficulty'])) | |
# setup state | |
for address, h in list(pre.items()): | |
assert len(address) == 40 | |
address = decode_hex(address) | |
assert set(h.keys()) == set(['code', 'nonce', 'balance', 'storage']) | |
state.set_nonce(address, parse_int_or_hex(h['nonce'])) | |
state.set_balance(address, parse_int_or_hex(h['balance'])) | |
state.set_code(address, decode_hex(h['code'][2:])) | |
for k, v in h['storage'].items(): | |
state.set_storage_data(address, | |
utils.big_endian_to_int(decode_hex(k[2:])), | |
decode_hex(v[2:])) | |
for address, h in list(pre.items()): | |
address = decode_hex(address) | |
assert state.get_nonce(address) == parse_int_or_hex(h['nonce']) | |
assert state.get_balance(address) == parse_int_or_hex(h['balance']) | |
assert state.get_code(address) == decode_hex(h['code'][2:]) | |
for k, v in h['storage'].items(): | |
assert state.get_storage_data(address, utils.big_endian_to_int( | |
decode_hex(k[2:]))) == utils.big_endian_to_int(decode_hex(v[2:])) | |
try: | |
tx = transactions.Transaction( | |
nonce=parse_int_or_hex(exek['nonce'] or b"0"), | |
gasprice=parse_int_or_hex(exek['gasPrice'] or b"0"), | |
startgas=parse_int_or_hex(exek['gasLimit'] or b"0"), | |
to=normalize_address(exek['to'], allow_blank=True), | |
value=parse_int_or_hex(exek['value'] or b"0"), | |
data=decode_hex(remove_0x_head(exek['data']))) | |
except InvalidTransaction: | |
tx = None | |
success, output = False, b'' | |
time_pre = time.time() | |
time_post = time_pre | |
state.commit(allow_empties=True) | |
else: | |
if 'secretKey' in exek: | |
tx.sign(exek['secretKey']) | |
elif all(key in exek for key in ['v', 'r', 's']): | |
tx.v = decode_hex(remove_0x_head(exek['v'])) | |
tx.r = decode_hex(remove_0x_head(exek['r'])) | |
tx.s = decode_hex(remove_0x_head(exek['s'])) | |
else: | |
assert False | |
time_pre = time.time() | |
state.commit(allow_empties=True) | |
snapshot = state.snapshot() | |
try: | |
print('trying') | |
success, output = state_transition.apply_transaction(state, tx) | |
logs = state.receipts[-1].logs | |
assert success | |
state.commit() | |
print('tx applied') | |
except InvalidTransaction: | |
success, output = False, b'' | |
state.commit() | |
pass | |
except AssertionError: | |
success, output = False, b'' | |
state.commit() | |
pass | |
time_post = time.time() | |
if tx.to == b'': | |
output = state.get_code(output) if output else b'' | |
params2 = copy.deepcopy(params) | |
if success: | |
params2['logs'] = [log.to_dict() for log in logs] | |
params2['out'] = '0x' + encode_hex(output) | |
params2['post'] = copy.deepcopy(state.to_dict()) | |
params2['postStateRoot'] = encode_hex(state.trie.root_hash) | |
if mode == FILL: | |
return params2 | |
elif mode == VERIFY: | |
params1 = copy.deepcopy(params) | |
shouldbe, reallyis = params1.get('post', None), params2.get('post', None) | |
compare_post_states(shouldbe, reallyis) | |
for k in ['pre', 'exec', 'env', 'callcreates', | |
'out', 'gas', 'logs', 'postStateRoot']: | |
_shouldbe = params1.get(k, None) | |
_reallyis = params2.get(k, None) | |
passed = False | |
if isinstance(_shouldbe, (str, bytes, unicode)) and _shouldbe[0] == '#': | |
if int(_shouldbe[1:]) == len(decode_hex(remove_0x_head(_reallyis))): | |
passed = True | |
if _shouldbe == _reallyis: | |
passed = True | |
if not passed: | |
print('s', shouldbe) | |
print('r', reallyis) | |
print(state.trie.to_dict()) | |
raise Exception("Mismatch: " + k + ':\n shouldbe %r\n reallyis %r' % | |
> (_shouldbe, _reallyis)) | |
E Exception: Mismatch: postStateRoot: | |
E shouldbe u'd2973c4abfcc5775a79c48621f1bcd0ebd72471853ba1d1c5116a423301db265' | |
E reallyis 'd89d14946c4b857d305d29221b4967867d49ea86124a2a9596fcb9a41597d751' | |
ethereum/testutils.py:409: Exception | |
----------------------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------------------ | |
trying | |
tx applied | |
('s', {u'a94f5374fce5edbc8e2a8697c15331677e6ebf0b': {u'nonce': u'0x01', u'balance': u'0x0de0b6b3a742c37c', u'storage': {}, u'code': u'0x'}, u'2adc25665018aa1fe0e6bc666dac8fc2697ff9ba': {u'nonce': u'0x00', u'balance': u'0x1fb5e4', u'storage': {}, u'code': u'0x'}, u'095e7baea6a6c7c4c2dfeb977efac326af552d87': {u'nonce': u'0x00', u'balance': u'0x0132b3a0', u'storage': {u'0x00': u'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}, u'code': u'0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60005260206000620f4240600060006003611770f1600255600051600055'}}) | |
('r', {'a94f5374fce5edbc8e2a8697c15331677e6ebf0b': {'nonce': '1', 'balance': '999999999997821820', 'storage': {}, 'code': '0x'}, '0000000000000000000000000000000000000003': {'nonce': '0', 'balance': '0', 'storage': {}, 'code': '0x'}, '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba': {'nonce': '0', 'balance': '2078180', 'storage': {}, 'code': '0x'}, '095e7baea6a6c7c4c2dfeb977efac326af552d87': {'nonce': '0', 'balance': '20100000', 'storage': {'00': 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}, 'code': '0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60005260206000620f4240600060006003611770f1600255600051600055'}}) | |
{'\xa9OSt\xfc\xe5\xed\xbc\x8e*\x86\x97\xc1S1g~n\xbf\x0b': "\xf8L\x01\x88\r\xe0\xb6\xb3\xa7B\xc3|\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p", '\t^{\xae\xa6\xa6\xc7\xc4\xc2\xdf\xeb\x97~\xfa\xc3&\xafU-\x87': "\xf8H\x80\x84\x012\xb3\xa0\xa0\xcao\x0f\xbd\xed\xa8\x18!o9\x9c9]\xc8\x14\x12\x1ef\xbc\xa0\x13\x9c\xef%\xa2\xb8\x12#\xc48\xc1\xf6\xa0\xcc%8\xbd\x04{\x07\xb8\xcal\xe6^\xe8r0\x19\xda\x92\x15\xe5\xb9'\x85\\\xd3J\xd9r\x81\xdfn\x1d", '*\xdc%fP\x18\xaa\x1f\xe0\xe6\xbcfm\xac\x8f\xc2i\x7f\xf9\xba': "\xf8G\x80\x83\x1f\xb5\xe4\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p", '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03': "\xf8D\x80\x80\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p"} | |
______________________________________________________________ test_state[fixtures/StateTests/stPreCompiledContracts.json-CallRipemd160_0-testdata646] ______________________________________________________________ | |
filename = 'fixtures/StateTests/stPreCompiledContracts.json', testname = 'CallRipemd160_0' | |
testdata = {'env': {'currentCoinbase': '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba', 'currentDifficulty': '0x0100', 'currentGasLimi...e5edbc8e2a8697c15331677e6ebf0b': {'balance': '0x0de0b6b3a761763f', 'code': '0x', 'nonce': '0x01', 'storage': {}}}, ...} | |
def test_state(filename, testname, testdata): | |
logger.debug('running test:%r in %r' % (testname, filename)) | |
> testutils.check_state_test(testutils.fixture_to_bytes(testdata)) | |
ethereum/tests/test_state.py:16: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
ethereum/testutils.py:51: in <lambda> | |
check_state_test = lambda params: run_state_test(params, VERIFY) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
params = {'env': {'currentCoinbase': '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba', 'currentDifficulty': '0x0100', 'currentGasLimi...e5edbc8e2a8697c15331677e6ebf0b': {'balance': '0x0de0b6b3a761763f', 'code': '0x', 'nonce': '0x01', 'storage': {}}}, ...} | |
mode = 2 | |
def run_state_test(params, mode): | |
pre = params['pre'] | |
exek = params['transaction'] | |
env = params['env'] | |
assert set(env.keys()) == set(['currentGasLimit', 'currentTimestamp', | |
'previousHash', 'currentCoinbase', | |
'currentDifficulty', 'currentNumber']) | |
assert len(env['currentCoinbase']) == 40 | |
konfig = copy.deepcopy(default_config) | |
# konfig['HOMESTEAD_FORK_BLKNUM'] = 1000000 | |
state = State(env=Env(db, konfig), | |
prev_headers=[mk_fake_header(i) for i in range(parse_int_or_hex(env['currentNumber']) -1, max(-1, parse_int_or_hex(env['currentNumber']) -257), -1)], | |
block_number=parse_int_or_hex(env['currentNumber']), | |
block_coinbase=utils.normalize_address(env['currentCoinbase']), | |
timestamp=parse_int_or_hex(env['currentTimestamp']), | |
gas_limit=parse_int_or_hex(env['currentGasLimit']), | |
block_difficulty=parse_int_or_hex(env['currentDifficulty'])) | |
# setup state | |
for address, h in list(pre.items()): | |
assert len(address) == 40 | |
address = decode_hex(address) | |
assert set(h.keys()) == set(['code', 'nonce', 'balance', 'storage']) | |
state.set_nonce(address, parse_int_or_hex(h['nonce'])) | |
state.set_balance(address, parse_int_or_hex(h['balance'])) | |
state.set_code(address, decode_hex(h['code'][2:])) | |
for k, v in h['storage'].items(): | |
state.set_storage_data(address, | |
utils.big_endian_to_int(decode_hex(k[2:])), | |
decode_hex(v[2:])) | |
for address, h in list(pre.items()): | |
address = decode_hex(address) | |
assert state.get_nonce(address) == parse_int_or_hex(h['nonce']) | |
assert state.get_balance(address) == parse_int_or_hex(h['balance']) | |
assert state.get_code(address) == decode_hex(h['code'][2:]) | |
for k, v in h['storage'].items(): | |
assert state.get_storage_data(address, utils.big_endian_to_int( | |
decode_hex(k[2:]))) == utils.big_endian_to_int(decode_hex(v[2:])) | |
try: | |
tx = transactions.Transaction( | |
nonce=parse_int_or_hex(exek['nonce'] or b"0"), | |
gasprice=parse_int_or_hex(exek['gasPrice'] or b"0"), | |
startgas=parse_int_or_hex(exek['gasLimit'] or b"0"), | |
to=normalize_address(exek['to'], allow_blank=True), | |
value=parse_int_or_hex(exek['value'] or b"0"), | |
data=decode_hex(remove_0x_head(exek['data']))) | |
except InvalidTransaction: | |
tx = None | |
success, output = False, b'' | |
time_pre = time.time() | |
time_post = time_pre | |
state.commit(allow_empties=True) | |
else: | |
if 'secretKey' in exek: | |
tx.sign(exek['secretKey']) | |
elif all(key in exek for key in ['v', 'r', 's']): | |
tx.v = decode_hex(remove_0x_head(exek['v'])) | |
tx.r = decode_hex(remove_0x_head(exek['r'])) | |
tx.s = decode_hex(remove_0x_head(exek['s'])) | |
else: | |
assert False | |
time_pre = time.time() | |
state.commit(allow_empties=True) | |
snapshot = state.snapshot() | |
try: | |
print('trying') | |
success, output = state_transition.apply_transaction(state, tx) | |
logs = state.receipts[-1].logs | |
assert success | |
state.commit() | |
print('tx applied') | |
except InvalidTransaction: | |
success, output = False, b'' | |
state.commit() | |
pass | |
except AssertionError: | |
success, output = False, b'' | |
state.commit() | |
pass | |
time_post = time.time() | |
if tx.to == b'': | |
output = state.get_code(output) if output else b'' | |
params2 = copy.deepcopy(params) | |
if success: | |
params2['logs'] = [log.to_dict() for log in logs] | |
params2['out'] = '0x' + encode_hex(output) | |
params2['post'] = copy.deepcopy(state.to_dict()) | |
params2['postStateRoot'] = encode_hex(state.trie.root_hash) | |
if mode == FILL: | |
return params2 | |
elif mode == VERIFY: | |
params1 = copy.deepcopy(params) | |
shouldbe, reallyis = params1.get('post', None), params2.get('post', None) | |
compare_post_states(shouldbe, reallyis) | |
for k in ['pre', 'exec', 'env', 'callcreates', | |
'out', 'gas', 'logs', 'postStateRoot']: | |
_shouldbe = params1.get(k, None) | |
_reallyis = params2.get(k, None) | |
passed = False | |
if isinstance(_shouldbe, (str, bytes, unicode)) and _shouldbe[0] == '#': | |
if int(_shouldbe[1:]) == len(decode_hex(remove_0x_head(_reallyis))): | |
passed = True | |
if _shouldbe == _reallyis: | |
passed = True | |
if not passed: | |
print('s', shouldbe) | |
print('r', reallyis) | |
print(state.trie.to_dict()) | |
raise Exception("Mismatch: " + k + ':\n shouldbe %r\n reallyis %r' % | |
> (_shouldbe, _reallyis)) | |
E Exception: Mismatch: postStateRoot: | |
E shouldbe u'b418cef120df01a9cef80804c2f883527c0b550df6664166857a7c998a869b65' | |
E reallyis '84cbde9ca2ff822f260ba51a331096e5fcb4b0f1177712d177a52fc55e2d8e9c' | |
ethereum/testutils.py:409: Exception | |
----------------------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------------------ | |
trying | |
tx applied | |
('s', {u'a94f5374fce5edbc8e2a8697c15331677e6ebf0b': {u'nonce': u'0x01', u'balance': u'0x0de0b6b3a761763f', u'storage': {}, u'code': u'0x'}, u'2adc25665018aa1fe0e6bc666dac8fc2697ff9ba': {u'nonce': u'0x00', u'balance': u'0x010321', u'storage': {}, u'code': u'0x'}, u'095e7baea6a6c7c4c2dfeb977efac326af552d87': {u'nonce': u'0x00', u'balance': u'0x0132b3a0', u'storage': {u'0x00': u'0x01'}, u'code': u'0x600160005260206000602060006000600360fff1600051600055'}}) | |
('r', {'a94f5374fce5edbc8e2a8697c15331677e6ebf0b': {'nonce': '1', 'balance': '999999999999833663', 'storage': {}, 'code': '0x'}, '0000000000000000000000000000000000000003': {'nonce': '0', 'balance': '0', 'storage': {}, 'code': '0x'}, '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba': {'nonce': '0', 'balance': '66337', 'storage': {}, 'code': '0x'}, '095e7baea6a6c7c4c2dfeb977efac326af552d87': {'nonce': '0', 'balance': '20100000', 'storage': {'00': '01'}, 'code': '0x600160005260206000602060006000600360fff1600051600055'}}) | |
{'\xa9OSt\xfc\xe5\xed\xbc\x8e*\x86\x97\xc1S1g~n\xbf\x0b': "\xf8L\x01\x88\r\xe0\xb6\xb3\xa7av?\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p", '\t^{\xae\xa6\xa6\xc7\xc4\xc2\xdf\xeb\x97~\xfa\xc3&\xafU-\x87': '\xf8H\x80\x84\x012\xb3\xa0\xa0\x82\x1e%V\xa2\x90\xc8d\x05\xf8\x16\n-f B\xa41\xbaEk\x9d\xb2e\xc7\x9b\xb87\xc0K\xe5\xf0\xa0\xc0}E\x17\xa1\x10P\x95\x1d\x80\xd1_Q\x1a\x9bJ\x1a\xdc\xca\xba\xa5\xba\xd6\xa6\xb5Y\x9bd\xe3\x14K\xdf', '*\xdc%fP\x18\xaa\x1f\xe0\xe6\xbcfm\xac\x8f\xc2i\x7f\xf9\xba': "\xf8G\x80\x83\x01\x03!\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p", '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03': "\xf8D\x80\x80\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p"} | |
__________________________________________________________ test_state[fixtures/StateTests/stPreCompiledContracts.json-CallRipemd160_4_gas719-testdata663] ___________________________________________________________ | |
filename = 'fixtures/StateTests/stPreCompiledContracts.json', testname = 'CallRipemd160_4_gas719' | |
testdata = {'env': {'currentCoinbase': '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba', 'currentDifficulty': '0x0100', 'currentGasLimi...e5edbc8e2a8697c15331677e6ebf0b': {'balance': '0x0de0b6b3a76160e4', 'code': '0x', 'nonce': '0x01', 'storage': {}}}, ...} | |
def test_state(filename, testname, testdata): | |
logger.debug('running test:%r in %r' % (testname, filename)) | |
> testutils.check_state_test(testutils.fixture_to_bytes(testdata)) | |
ethereum/tests/test_state.py:16: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
ethereum/testutils.py:51: in <lambda> | |
check_state_test = lambda params: run_state_test(params, VERIFY) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
params = {'env': {'currentCoinbase': '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba', 'currentDifficulty': '0x0100', 'currentGasLimi...e5edbc8e2a8697c15331677e6ebf0b': {'balance': '0x0de0b6b3a76160e4', 'code': '0x', 'nonce': '0x01', 'storage': {}}}, ...} | |
mode = 2 | |
def run_state_test(params, mode): | |
pre = params['pre'] | |
exek = params['transaction'] | |
env = params['env'] | |
assert set(env.keys()) == set(['currentGasLimit', 'currentTimestamp', | |
'previousHash', 'currentCoinbase', | |
'currentDifficulty', 'currentNumber']) | |
assert len(env['currentCoinbase']) == 40 | |
konfig = copy.deepcopy(default_config) | |
# konfig['HOMESTEAD_FORK_BLKNUM'] = 1000000 | |
state = State(env=Env(db, konfig), | |
prev_headers=[mk_fake_header(i) for i in range(parse_int_or_hex(env['currentNumber']) -1, max(-1, parse_int_or_hex(env['currentNumber']) -257), -1)], | |
block_number=parse_int_or_hex(env['currentNumber']), | |
block_coinbase=utils.normalize_address(env['currentCoinbase']), | |
timestamp=parse_int_or_hex(env['currentTimestamp']), | |
gas_limit=parse_int_or_hex(env['currentGasLimit']), | |
block_difficulty=parse_int_or_hex(env['currentDifficulty'])) | |
# setup state | |
for address, h in list(pre.items()): | |
assert len(address) == 40 | |
address = decode_hex(address) | |
assert set(h.keys()) == set(['code', 'nonce', 'balance', 'storage']) | |
state.set_nonce(address, parse_int_or_hex(h['nonce'])) | |
state.set_balance(address, parse_int_or_hex(h['balance'])) | |
state.set_code(address, decode_hex(h['code'][2:])) | |
for k, v in h['storage'].items(): | |
state.set_storage_data(address, | |
utils.big_endian_to_int(decode_hex(k[2:])), | |
decode_hex(v[2:])) | |
for address, h in list(pre.items()): | |
address = decode_hex(address) | |
assert state.get_nonce(address) == parse_int_or_hex(h['nonce']) | |
assert state.get_balance(address) == parse_int_or_hex(h['balance']) | |
assert state.get_code(address) == decode_hex(h['code'][2:]) | |
for k, v in h['storage'].items(): | |
assert state.get_storage_data(address, utils.big_endian_to_int( | |
decode_hex(k[2:]))) == utils.big_endian_to_int(decode_hex(v[2:])) | |
try: | |
tx = transactions.Transaction( | |
nonce=parse_int_or_hex(exek['nonce'] or b"0"), | |
gasprice=parse_int_or_hex(exek['gasPrice'] or b"0"), | |
startgas=parse_int_or_hex(exek['gasLimit'] or b"0"), | |
to=normalize_address(exek['to'], allow_blank=True), | |
value=parse_int_or_hex(exek['value'] or b"0"), | |
data=decode_hex(remove_0x_head(exek['data']))) | |
except InvalidTransaction: | |
tx = None | |
success, output = False, b'' | |
time_pre = time.time() | |
time_post = time_pre | |
state.commit(allow_empties=True) | |
else: | |
if 'secretKey' in exek: | |
tx.sign(exek['secretKey']) | |
elif all(key in exek for key in ['v', 'r', 's']): | |
tx.v = decode_hex(remove_0x_head(exek['v'])) | |
tx.r = decode_hex(remove_0x_head(exek['r'])) | |
tx.s = decode_hex(remove_0x_head(exek['s'])) | |
else: | |
assert False | |
time_pre = time.time() | |
state.commit(allow_empties=True) | |
snapshot = state.snapshot() | |
try: | |
print('trying') | |
success, output = state_transition.apply_transaction(state, tx) | |
logs = state.receipts[-1].logs | |
assert success | |
state.commit() | |
print('tx applied') | |
except InvalidTransaction: | |
success, output = False, b'' | |
state.commit() | |
pass | |
except AssertionError: | |
success, output = False, b'' | |
state.commit() | |
pass | |
time_post = time.time() | |
if tx.to == b'': | |
output = state.get_code(output) if output else b'' | |
params2 = copy.deepcopy(params) | |
if success: | |
params2['logs'] = [log.to_dict() for log in logs] | |
params2['out'] = '0x' + encode_hex(output) | |
params2['post'] = copy.deepcopy(state.to_dict()) | |
params2['postStateRoot'] = encode_hex(state.trie.root_hash) | |
if mode == FILL: | |
return params2 | |
elif mode == VERIFY: | |
params1 = copy.deepcopy(params) | |
shouldbe, reallyis = params1.get('post', None), params2.get('post', None) | |
compare_post_states(shouldbe, reallyis) | |
for k in ['pre', 'exec', 'env', 'callcreates', | |
'out', 'gas', 'logs', 'postStateRoot']: | |
_shouldbe = params1.get(k, None) | |
_reallyis = params2.get(k, None) | |
passed = False | |
if isinstance(_shouldbe, (str, bytes, unicode)) and _shouldbe[0] == '#': | |
if int(_shouldbe[1:]) == len(decode_hex(remove_0x_head(_reallyis))): | |
passed = True | |
if _shouldbe == _reallyis: | |
passed = True | |
if not passed: | |
print('s', shouldbe) | |
print('r', reallyis) | |
print(state.trie.to_dict()) | |
raise Exception("Mismatch: " + k + ':\n shouldbe %r\n reallyis %r' % | |
> (_shouldbe, _reallyis)) | |
E Exception: Mismatch: postStateRoot: | |
E shouldbe u'1e83dde333b6e3f50223781c584bdc334145e3e58b0cea77c76e6247f2b58fa0' | |
E reallyis '6c90bbf3a4a4eac4f4741c311822048b3d786c40fa04c90fd25279fd26f4d01f' | |
ethereum/testutils.py:409: Exception | |
----------------------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------------------ | |
trying | |
tx applied | |
('s', {u'a94f5374fce5edbc8e2a8697c15331677e6ebf0b': {u'nonce': u'0x01', u'balance': u'0x0de0b6b3a76160e4', u'storage': {}, u'code': u'0x'}, u'2adc25665018aa1fe0e6bc666dac8fc2697ff9ba': {u'nonce': u'0x00', u'balance': u'0x01187c', u'storage': {}, u'code': u'0x'}, u'095e7baea6a6c7c4c2dfeb977efac326af552d87': {u'nonce': u'0x00', u'balance': u'0x0132b3a0', u'storage': {u'0x00': u'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}, u'code': u'0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000526020600060206000600060036102cff1600255600051600055'}}) | |
('r', {'a94f5374fce5edbc8e2a8697c15331677e6ebf0b': {'nonce': '1', 'balance': '999999999999828196', 'storage': {}, 'code': '0x'}, '0000000000000000000000000000000000000003': {'nonce': '0', 'balance': '0', 'storage': {}, 'code': '0x'}, '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba': {'nonce': '0', 'balance': '71804', 'storage': {}, 'code': '0x'}, '095e7baea6a6c7c4c2dfeb977efac326af552d87': {'nonce': '0', 'balance': '20100000', 'storage': {'00': 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}, 'code': '0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000526020600060206000600060036102cff1600255600051600055'}}) | |
{'\xa9OSt\xfc\xe5\xed\xbc\x8e*\x86\x97\xc1S1g~n\xbf\x0b': "\xf8L\x01\x88\r\xe0\xb6\xb3\xa7a`\xe4\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p", '\t^{\xae\xa6\xa6\xc7\xc4\xc2\xdf\xeb\x97~\xfa\xc3&\xafU-\x87': "\xf8H\x80\x84\x012\xb3\xa0\xa0\xcao\x0f\xbd\xed\xa8\x18!o9\x9c9]\xc8\x14\x12\x1ef\xbc\xa0\x13\x9c\xef%\xa2\xb8\x12#\xc48\xc1\xf6\xa0xRm\xcdfd\xf1x{\xca5'\x85\x8c\xdc\xfeQ+\x7f\x1f\xe1\xef>\xfb<8Z\x88\xc7\xe04\xe0", '*\xdc%fP\x18\xaa\x1f\xe0\xe6\xbcfm\xac\x8f\xc2i\x7f\xf9\xba': "\xf8G\x80\x83\x01\x18|\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p", '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03': "\xf8D\x80\x80\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p"} | |
_____________________________________________________ test_state[fixtures/StateTests/EIP150/Homestead/stPreCompiledContracts.json-CallRipemd160_5-testdata3265] _____________________________________________________ | |
filename = 'fixtures/StateTests/EIP150/Homestead/stPreCompiledContracts.json', testname = 'CallRipemd160_5' | |
testdata = {'env': {'currentCoinbase': '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba', 'currentDifficulty': '0x0100', 'currentGasLimi...e5edbc8e2a8697c15331677e6ebf0b': {'balance': '0x0de0b6b3a742c0e8', 'code': '0x', 'nonce': '0x01', 'storage': {}}}, ...} | |
def test_state(filename, testname, testdata): | |
logger.debug('running test:%r in %r' % (testname, filename)) | |
> testutils.check_state_test(testutils.fixture_to_bytes(testdata)) | |
ethereum/tests/test_state.py:16: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
ethereum/testutils.py:51: in <lambda> | |
check_state_test = lambda params: run_state_test(params, VERIFY) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
params = {'env': {'currentCoinbase': '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba', 'currentDifficulty': '0x0100', 'currentGasLimi...e5edbc8e2a8697c15331677e6ebf0b': {'balance': '0x0de0b6b3a742c0e8', 'code': '0x', 'nonce': '0x01', 'storage': {}}}, ...} | |
mode = 2 | |
def run_state_test(params, mode): | |
pre = params['pre'] | |
exek = params['transaction'] | |
env = params['env'] | |
assert set(env.keys()) == set(['currentGasLimit', 'currentTimestamp', | |
'previousHash', 'currentCoinbase', | |
'currentDifficulty', 'currentNumber']) | |
assert len(env['currentCoinbase']) == 40 | |
konfig = copy.deepcopy(default_config) | |
# konfig['HOMESTEAD_FORK_BLKNUM'] = 1000000 | |
state = State(env=Env(db, konfig), | |
prev_headers=[mk_fake_header(i) for i in range(parse_int_or_hex(env['currentNumber']) -1, max(-1, parse_int_or_hex(env['currentNumber']) -257), -1)], | |
block_number=parse_int_or_hex(env['currentNumber']), | |
block_coinbase=utils.normalize_address(env['currentCoinbase']), | |
timestamp=parse_int_or_hex(env['currentTimestamp']), | |
gas_limit=parse_int_or_hex(env['currentGasLimit']), | |
block_difficulty=parse_int_or_hex(env['currentDifficulty'])) | |
# setup state | |
for address, h in list(pre.items()): | |
assert len(address) == 40 | |
address = decode_hex(address) | |
assert set(h.keys()) == set(['code', 'nonce', 'balance', 'storage']) | |
state.set_nonce(address, parse_int_or_hex(h['nonce'])) | |
state.set_balance(address, parse_int_or_hex(h['balance'])) | |
state.set_code(address, decode_hex(h['code'][2:])) | |
for k, v in h['storage'].items(): | |
state.set_storage_data(address, | |
utils.big_endian_to_int(decode_hex(k[2:])), | |
decode_hex(v[2:])) | |
for address, h in list(pre.items()): | |
address = decode_hex(address) | |
assert state.get_nonce(address) == parse_int_or_hex(h['nonce']) | |
assert state.get_balance(address) == parse_int_or_hex(h['balance']) | |
assert state.get_code(address) == decode_hex(h['code'][2:]) | |
for k, v in h['storage'].items(): | |
assert state.get_storage_data(address, utils.big_endian_to_int( | |
decode_hex(k[2:]))) == utils.big_endian_to_int(decode_hex(v[2:])) | |
try: | |
tx = transactions.Transaction( | |
nonce=parse_int_or_hex(exek['nonce'] or b"0"), | |
gasprice=parse_int_or_hex(exek['gasPrice'] or b"0"), | |
startgas=parse_int_or_hex(exek['gasLimit'] or b"0"), | |
to=normalize_address(exek['to'], allow_blank=True), | |
value=parse_int_or_hex(exek['value'] or b"0"), | |
data=decode_hex(remove_0x_head(exek['data']))) | |
except InvalidTransaction: | |
tx = None | |
success, output = False, b'' | |
time_pre = time.time() | |
time_post = time_pre | |
state.commit(allow_empties=True) | |
else: | |
if 'secretKey' in exek: | |
tx.sign(exek['secretKey']) | |
elif all(key in exek for key in ['v', 'r', 's']): | |
tx.v = decode_hex(remove_0x_head(exek['v'])) | |
tx.r = decode_hex(remove_0x_head(exek['r'])) | |
tx.s = decode_hex(remove_0x_head(exek['s'])) | |
else: | |
assert False | |
time_pre = time.time() | |
state.commit(allow_empties=True) | |
snapshot = state.snapshot() | |
try: | |
print('trying') | |
success, output = state_transition.apply_transaction(state, tx) | |
logs = state.receipts[-1].logs | |
assert success | |
state.commit() | |
print('tx applied') | |
except InvalidTransaction: | |
success, output = False, b'' | |
state.commit() | |
pass | |
except AssertionError: | |
success, output = False, b'' | |
state.commit() | |
pass | |
time_post = time.time() | |
if tx.to == b'': | |
output = state.get_code(output) if output else b'' | |
params2 = copy.deepcopy(params) | |
if success: | |
params2['logs'] = [log.to_dict() for log in logs] | |
params2['out'] = '0x' + encode_hex(output) | |
params2['post'] = copy.deepcopy(state.to_dict()) | |
params2['postStateRoot'] = encode_hex(state.trie.root_hash) | |
if mode == FILL: | |
return params2 | |
elif mode == VERIFY: | |
params1 = copy.deepcopy(params) | |
shouldbe, reallyis = params1.get('post', None), params2.get('post', None) | |
compare_post_states(shouldbe, reallyis) | |
for k in ['pre', 'exec', 'env', 'callcreates', | |
'out', 'gas', 'logs', 'postStateRoot']: | |
_shouldbe = params1.get(k, None) | |
_reallyis = params2.get(k, None) | |
passed = False | |
if isinstance(_shouldbe, (str, bytes, unicode)) and _shouldbe[0] == '#': | |
if int(_shouldbe[1:]) == len(decode_hex(remove_0x_head(_reallyis))): | |
passed = True | |
if _shouldbe == _reallyis: | |
passed = True | |
if not passed: | |
print('s', shouldbe) | |
print('r', reallyis) | |
print(state.trie.to_dict()) | |
raise Exception("Mismatch: " + k + ':\n shouldbe %r\n reallyis %r' % | |
> (_shouldbe, _reallyis)) | |
E Exception: Mismatch: postStateRoot: | |
E shouldbe u'b9f2484fa66f67ec3abb57c35024cb90c67237c7a800a083d6dedba49d4393aa' | |
E reallyis 'ed72dded2bf07003be83e4d129c7de4770a93ffea49ff21d764dc4a8daf8cf74' | |
ethereum/testutils.py:409: Exception | |
----------------------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------------------ | |
trying | |
tx applied | |
('s', {u'a94f5374fce5edbc8e2a8697c15331677e6ebf0b': {u'nonce': u'0x01', u'balance': u'0x0de0b6b3a742c0e8', u'storage': {}, u'code': u'0x'}, u'2adc25665018aa1fe0e6bc666dac8fc2697ff9ba': {u'nonce': u'0x00', u'balance': u'0x1fb878', u'storage': {}, u'code': u'0x'}, u'095e7baea6a6c7c4c2dfeb977efac326af552d87': {u'nonce': u'0x00', u'balance': u'0x0132b3a0', u'storage': {u'0x00': u'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}, u'code': u'0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60005260206000620f4240600060006003611770f1600255600051600055'}}) | |
('r', {'a94f5374fce5edbc8e2a8697c15331677e6ebf0b': {'nonce': '1', 'balance': '999999999997821160', 'storage': {}, 'code': '0x'}, '0000000000000000000000000000000000000003': {'nonce': '0', 'balance': '0', 'storage': {}, 'code': '0x'}, '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba': {'nonce': '0', 'balance': '2078840', 'storage': {}, 'code': '0x'}, '095e7baea6a6c7c4c2dfeb977efac326af552d87': {'nonce': '0', 'balance': '20100000', 'storage': {'00': 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}, 'code': '0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60005260206000620f4240600060006003611770f1600255600051600055'}}) | |
{'\xa9OSt\xfc\xe5\xed\xbc\x8e*\x86\x97\xc1S1g~n\xbf\x0b': "\xf8L\x01\x88\r\xe0\xb6\xb3\xa7B\xc0\xe8\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p", '\t^{\xae\xa6\xa6\xc7\xc4\xc2\xdf\xeb\x97~\xfa\xc3&\xafU-\x87': "\xf8H\x80\x84\x012\xb3\xa0\xa0\xcao\x0f\xbd\xed\xa8\x18!o9\x9c9]\xc8\x14\x12\x1ef\xbc\xa0\x13\x9c\xef%\xa2\xb8\x12#\xc48\xc1\xf6\xa0\xcc%8\xbd\x04{\x07\xb8\xcal\xe6^\xe8r0\x19\xda\x92\x15\xe5\xb9'\x85\\\xd3J\xd9r\x81\xdfn\x1d", '*\xdc%fP\x18\xaa\x1f\xe0\xe6\xbcfm\xac\x8f\xc2i\x7f\xf9\xba': "\xf8G\x80\x83\x1f\xb8x\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p", '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03': "\xf8D\x80\x80\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p"} | |
_____________________________________________________ test_state[fixtures/StateTests/EIP150/Homestead/stPreCompiledContracts.json-CallRipemd160_0-testdata3268] _____________________________________________________ | |
filename = 'fixtures/StateTests/EIP150/Homestead/stPreCompiledContracts.json', testname = 'CallRipemd160_0' | |
testdata = {'env': {'currentCoinbase': '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba', 'currentDifficulty': '0x0100', 'currentGasLimi...e5edbc8e2a8697c15331677e6ebf0b': {'balance': '0x0de0b6b3a76173ab', 'code': '0x', 'nonce': '0x01', 'storage': {}}}, ...} | |
def test_state(filename, testname, testdata): | |
logger.debug('running test:%r in %r' % (testname, filename)) | |
> testutils.check_state_test(testutils.fixture_to_bytes(testdata)) | |
ethereum/tests/test_state.py:16: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
ethereum/testutils.py:51: in <lambda> | |
check_state_test = lambda params: run_state_test(params, VERIFY) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
params = {'env': {'currentCoinbase': '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba', 'currentDifficulty': '0x0100', 'currentGasLimi...e5edbc8e2a8697c15331677e6ebf0b': {'balance': '0x0de0b6b3a76173ab', 'code': '0x', 'nonce': '0x01', 'storage': {}}}, ...} | |
mode = 2 | |
def run_state_test(params, mode): | |
pre = params['pre'] | |
exek = params['transaction'] | |
env = params['env'] | |
assert set(env.keys()) == set(['currentGasLimit', 'currentTimestamp', | |
'previousHash', 'currentCoinbase', | |
'currentDifficulty', 'currentNumber']) | |
assert len(env['currentCoinbase']) == 40 | |
konfig = copy.deepcopy(default_config) | |
# konfig['HOMESTEAD_FORK_BLKNUM'] = 1000000 | |
state = State(env=Env(db, konfig), | |
prev_headers=[mk_fake_header(i) for i in range(parse_int_or_hex(env['currentNumber']) -1, max(-1, parse_int_or_hex(env['currentNumber']) -257), -1)], | |
block_number=parse_int_or_hex(env['currentNumber']), | |
block_coinbase=utils.normalize_address(env['currentCoinbase']), | |
timestamp=parse_int_or_hex(env['currentTimestamp']), | |
gas_limit=parse_int_or_hex(env['currentGasLimit']), | |
block_difficulty=parse_int_or_hex(env['currentDifficulty'])) | |
# setup state | |
for address, h in list(pre.items()): | |
assert len(address) == 40 | |
address = decode_hex(address) | |
assert set(h.keys()) == set(['code', 'nonce', 'balance', 'storage']) | |
state.set_nonce(address, parse_int_or_hex(h['nonce'])) | |
state.set_balance(address, parse_int_or_hex(h['balance'])) | |
state.set_code(address, decode_hex(h['code'][2:])) | |
for k, v in h['storage'].items(): | |
state.set_storage_data(address, | |
utils.big_endian_to_int(decode_hex(k[2:])), | |
decode_hex(v[2:])) | |
for address, h in list(pre.items()): | |
address = decode_hex(address) | |
assert state.get_nonce(address) == parse_int_or_hex(h['nonce']) | |
assert state.get_balance(address) == parse_int_or_hex(h['balance']) | |
assert state.get_code(address) == decode_hex(h['code'][2:]) | |
for k, v in h['storage'].items(): | |
assert state.get_storage_data(address, utils.big_endian_to_int( | |
decode_hex(k[2:]))) == utils.big_endian_to_int(decode_hex(v[2:])) | |
try: | |
tx = transactions.Transaction( | |
nonce=parse_int_or_hex(exek['nonce'] or b"0"), | |
gasprice=parse_int_or_hex(exek['gasPrice'] or b"0"), | |
startgas=parse_int_or_hex(exek['gasLimit'] or b"0"), | |
to=normalize_address(exek['to'], allow_blank=True), | |
value=parse_int_or_hex(exek['value'] or b"0"), | |
data=decode_hex(remove_0x_head(exek['data']))) | |
except InvalidTransaction: | |
tx = None | |
success, output = False, b'' | |
time_pre = time.time() | |
time_post = time_pre | |
state.commit(allow_empties=True) | |
else: | |
if 'secretKey' in exek: | |
tx.sign(exek['secretKey']) | |
elif all(key in exek for key in ['v', 'r', 's']): | |
tx.v = decode_hex(remove_0x_head(exek['v'])) | |
tx.r = decode_hex(remove_0x_head(exek['r'])) | |
tx.s = decode_hex(remove_0x_head(exek['s'])) | |
else: | |
assert False | |
time_pre = time.time() | |
state.commit(allow_empties=True) | |
snapshot = state.snapshot() | |
try: | |
print('trying') | |
success, output = state_transition.apply_transaction(state, tx) | |
logs = state.receipts[-1].logs | |
assert success | |
state.commit() | |
print('tx applied') | |
except InvalidTransaction: | |
success, output = False, b'' | |
state.commit() | |
pass | |
except AssertionError: | |
success, output = False, b'' | |
state.commit() | |
pass | |
time_post = time.time() | |
if tx.to == b'': | |
output = state.get_code(output) if output else b'' | |
params2 = copy.deepcopy(params) | |
if success: | |
params2['logs'] = [log.to_dict() for log in logs] | |
params2['out'] = '0x' + encode_hex(output) | |
params2['post'] = copy.deepcopy(state.to_dict()) | |
params2['postStateRoot'] = encode_hex(state.trie.root_hash) | |
if mode == FILL: | |
return params2 | |
elif mode == VERIFY: | |
params1 = copy.deepcopy(params) | |
shouldbe, reallyis = params1.get('post', None), params2.get('post', None) | |
compare_post_states(shouldbe, reallyis) | |
for k in ['pre', 'exec', 'env', 'callcreates', | |
'out', 'gas', 'logs', 'postStateRoot']: | |
_shouldbe = params1.get(k, None) | |
_reallyis = params2.get(k, None) | |
passed = False | |
if isinstance(_shouldbe, (str, bytes, unicode)) and _shouldbe[0] == '#': | |
if int(_shouldbe[1:]) == len(decode_hex(remove_0x_head(_reallyis))): | |
passed = True | |
if _shouldbe == _reallyis: | |
passed = True | |
if not passed: | |
print('s', shouldbe) | |
print('r', reallyis) | |
print(state.trie.to_dict()) | |
raise Exception("Mismatch: " + k + ':\n shouldbe %r\n reallyis %r' % | |
> (_shouldbe, _reallyis)) | |
E Exception: Mismatch: postStateRoot: | |
E shouldbe u'686c6f0235678010e68839c7ba72cd39ed5b7de6475ebf2f1a42ed3056c445d6' | |
E reallyis '00409cb8e92f89cab4fc2d326d092c1128a8dcd87e935b2cecbfbd2166fc184e' | |
ethereum/testutils.py:409: Exception | |
----------------------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------------------ | |
trying | |
tx applied | |
('s', {u'a94f5374fce5edbc8e2a8697c15331677e6ebf0b': {u'nonce': u'0x01', u'balance': u'0x0de0b6b3a76173ab', u'storage': {}, u'code': u'0x'}, u'2adc25665018aa1fe0e6bc666dac8fc2697ff9ba': {u'nonce': u'0x00', u'balance': u'0x0105b5', u'storage': {}, u'code': u'0x'}, u'095e7baea6a6c7c4c2dfeb977efac326af552d87': {u'nonce': u'0x00', u'balance': u'0x0132b3a0', u'storage': {u'0x00': u'0x01'}, u'code': u'0x600160005260206000602060006000600360fff1600051600055'}}) | |
('r', {'a94f5374fce5edbc8e2a8697c15331677e6ebf0b': {'nonce': '1', 'balance': '999999999999833003', 'storage': {}, 'code': '0x'}, '0000000000000000000000000000000000000003': {'nonce': '0', 'balance': '0', 'storage': {}, 'code': '0x'}, '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba': {'nonce': '0', 'balance': '66997', 'storage': {}, 'code': '0x'}, '095e7baea6a6c7c4c2dfeb977efac326af552d87': {'nonce': '0', 'balance': '20100000', 'storage': {'00': '01'}, 'code': '0x600160005260206000602060006000600360fff1600051600055'}}) | |
{'\xa9OSt\xfc\xe5\xed\xbc\x8e*\x86\x97\xc1S1g~n\xbf\x0b': "\xf8L\x01\x88\r\xe0\xb6\xb3\xa7as\xab\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p", '\t^{\xae\xa6\xa6\xc7\xc4\xc2\xdf\xeb\x97~\xfa\xc3&\xafU-\x87': '\xf8H\x80\x84\x012\xb3\xa0\xa0\x82\x1e%V\xa2\x90\xc8d\x05\xf8\x16\n-f B\xa41\xbaEk\x9d\xb2e\xc7\x9b\xb87\xc0K\xe5\xf0\xa0\xc0}E\x17\xa1\x10P\x95\x1d\x80\xd1_Q\x1a\x9bJ\x1a\xdc\xca\xba\xa5\xba\xd6\xa6\xb5Y\x9bd\xe3\x14K\xdf', '*\xdc%fP\x18\xaa\x1f\xe0\xe6\xbcfm\xac\x8f\xc2i\x7f\xf9\xba': "\xf8G\x80\x83\x01\x05\xb5\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p", '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03': "\xf8D\x80\x80\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p"} | |
_________________________________________________ test_state[fixtures/StateTests/EIP150/Homestead/stPreCompiledContracts.json-CallRipemd160_4_gas719-testdata3285] __________________________________________________ | |
filename = 'fixtures/StateTests/EIP150/Homestead/stPreCompiledContracts.json', testname = 'CallRipemd160_4_gas719' | |
testdata = {'env': {'currentCoinbase': '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba', 'currentDifficulty': '0x0100', 'currentGasLimi...e5edbc8e2a8697c15331677e6ebf0b': {'balance': '0x0de0b6b3a7615e50', 'code': '0x', 'nonce': '0x01', 'storage': {}}}, ...} | |
def test_state(filename, testname, testdata): | |
logger.debug('running test:%r in %r' % (testname, filename)) | |
> testutils.check_state_test(testutils.fixture_to_bytes(testdata)) | |
ethereum/tests/test_state.py:16: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
ethereum/testutils.py:51: in <lambda> | |
check_state_test = lambda params: run_state_test(params, VERIFY) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
params = {'env': {'currentCoinbase': '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba', 'currentDifficulty': '0x0100', 'currentGasLimi...e5edbc8e2a8697c15331677e6ebf0b': {'balance': '0x0de0b6b3a7615e50', 'code': '0x', 'nonce': '0x01', 'storage': {}}}, ...} | |
mode = 2 | |
def run_state_test(params, mode): | |
pre = params['pre'] | |
exek = params['transaction'] | |
env = params['env'] | |
assert set(env.keys()) == set(['currentGasLimit', 'currentTimestamp', | |
'previousHash', 'currentCoinbase', | |
'currentDifficulty', 'currentNumber']) | |
assert len(env['currentCoinbase']) == 40 | |
konfig = copy.deepcopy(default_config) | |
# konfig['HOMESTEAD_FORK_BLKNUM'] = 1000000 | |
state = State(env=Env(db, konfig), | |
prev_headers=[mk_fake_header(i) for i in range(parse_int_or_hex(env['currentNumber']) -1, max(-1, parse_int_or_hex(env['currentNumber']) -257), -1)], | |
block_number=parse_int_or_hex(env['currentNumber']), | |
block_coinbase=utils.normalize_address(env['currentCoinbase']), | |
timestamp=parse_int_or_hex(env['currentTimestamp']), | |
gas_limit=parse_int_or_hex(env['currentGasLimit']), | |
block_difficulty=parse_int_or_hex(env['currentDifficulty'])) | |
# setup state | |
for address, h in list(pre.items()): | |
assert len(address) == 40 | |
address = decode_hex(address) | |
assert set(h.keys()) == set(['code', 'nonce', 'balance', 'storage']) | |
state.set_nonce(address, parse_int_or_hex(h['nonce'])) | |
state.set_balance(address, parse_int_or_hex(h['balance'])) | |
state.set_code(address, decode_hex(h['code'][2:])) | |
for k, v in h['storage'].items(): | |
state.set_storage_data(address, | |
utils.big_endian_to_int(decode_hex(k[2:])), | |
decode_hex(v[2:])) | |
for address, h in list(pre.items()): | |
address = decode_hex(address) | |
assert state.get_nonce(address) == parse_int_or_hex(h['nonce']) | |
assert state.get_balance(address) == parse_int_or_hex(h['balance']) | |
assert state.get_code(address) == decode_hex(h['code'][2:]) | |
for k, v in h['storage'].items(): | |
assert state.get_storage_data(address, utils.big_endian_to_int( | |
decode_hex(k[2:]))) == utils.big_endian_to_int(decode_hex(v[2:])) | |
try: | |
tx = transactions.Transaction( | |
nonce=parse_int_or_hex(exek['nonce'] or b"0"), | |
gasprice=parse_int_or_hex(exek['gasPrice'] or b"0"), | |
startgas=parse_int_or_hex(exek['gasLimit'] or b"0"), | |
to=normalize_address(exek['to'], allow_blank=True), | |
value=parse_int_or_hex(exek['value'] or b"0"), | |
data=decode_hex(remove_0x_head(exek['data']))) | |
except InvalidTransaction: | |
tx = None | |
success, output = False, b'' | |
time_pre = time.time() | |
time_post = time_pre | |
state.commit(allow_empties=True) | |
else: | |
if 'secretKey' in exek: | |
tx.sign(exek['secretKey']) | |
elif all(key in exek for key in ['v', 'r', 's']): | |
tx.v = decode_hex(remove_0x_head(exek['v'])) | |
tx.r = decode_hex(remove_0x_head(exek['r'])) | |
tx.s = decode_hex(remove_0x_head(exek['s'])) | |
else: | |
assert False | |
time_pre = time.time() | |
state.commit(allow_empties=True) | |
snapshot = state.snapshot() | |
try: | |
print('trying') | |
success, output = state_transition.apply_transaction(state, tx) | |
logs = state.receipts[-1].logs | |
assert success | |
state.commit() | |
print('tx applied') | |
except InvalidTransaction: | |
success, output = False, b'' | |
state.commit() | |
pass | |
except AssertionError: | |
success, output = False, b'' | |
state.commit() | |
pass | |
time_post = time.time() | |
if tx.to == b'': | |
output = state.get_code(output) if output else b'' | |
params2 = copy.deepcopy(params) | |
if success: | |
params2['logs'] = [log.to_dict() for log in logs] | |
params2['out'] = '0x' + encode_hex(output) | |
params2['post'] = copy.deepcopy(state.to_dict()) | |
params2['postStateRoot'] = encode_hex(state.trie.root_hash) | |
if mode == FILL: | |
return params2 | |
elif mode == VERIFY: | |
params1 = copy.deepcopy(params) | |
shouldbe, reallyis = params1.get('post', None), params2.get('post', None) | |
compare_post_states(shouldbe, reallyis) | |
for k in ['pre', 'exec', 'env', 'callcreates', | |
'out', 'gas', 'logs', 'postStateRoot']: | |
_shouldbe = params1.get(k, None) | |
_reallyis = params2.get(k, None) | |
passed = False | |
if isinstance(_shouldbe, (str, bytes, unicode)) and _shouldbe[0] == '#': | |
if int(_shouldbe[1:]) == len(decode_hex(remove_0x_head(_reallyis))): | |
passed = True | |
if _shouldbe == _reallyis: | |
passed = True | |
if not passed: | |
print('s', shouldbe) | |
print('r', reallyis) | |
print(state.trie.to_dict()) | |
raise Exception("Mismatch: " + k + ':\n shouldbe %r\n reallyis %r' % | |
> (_shouldbe, _reallyis)) | |
E Exception: Mismatch: postStateRoot: | |
E shouldbe u'231af4ae84d086a74ccea9af42af14de47f48fe18ec565de095f5987b85ce933' | |
E reallyis '181ab2b5aa8d36399f94d0bf3dd3db6a6103f246eaf892c023aa630d06e88479' | |
ethereum/testutils.py:409: Exception | |
----------------------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------------------ | |
trying | |
tx applied | |
('s', {u'a94f5374fce5edbc8e2a8697c15331677e6ebf0b': {u'nonce': u'0x01', u'balance': u'0x0de0b6b3a7615e50', u'storage': {}, u'code': u'0x'}, u'2adc25665018aa1fe0e6bc666dac8fc2697ff9ba': {u'nonce': u'0x00', u'balance': u'0x011b10', u'storage': {}, u'code': u'0x'}, u'095e7baea6a6c7c4c2dfeb977efac326af552d87': {u'nonce': u'0x00', u'balance': u'0x0132b3a0', u'storage': {u'0x00': u'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}, u'code': u'0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000526020600060206000600060036102cff1600255600051600055'}}) | |
('r', {'a94f5374fce5edbc8e2a8697c15331677e6ebf0b': {'nonce': '1', 'balance': '999999999999827536', 'storage': {}, 'code': '0x'}, '0000000000000000000000000000000000000003': {'nonce': '0', 'balance': '0', 'storage': {}, 'code': '0x'}, '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba': {'nonce': '0', 'balance': '72464', 'storage': {}, 'code': '0x'}, '095e7baea6a6c7c4c2dfeb977efac326af552d87': {'nonce': '0', 'balance': '20100000', 'storage': {'00': 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}, 'code': '0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000526020600060206000600060036102cff1600255600051600055'}}) | |
{'\xa9OSt\xfc\xe5\xed\xbc\x8e*\x86\x97\xc1S1g~n\xbf\x0b': "\xf8L\x01\x88\r\xe0\xb6\xb3\xa7a^P\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p", '\t^{\xae\xa6\xa6\xc7\xc4\xc2\xdf\xeb\x97~\xfa\xc3&\xafU-\x87': "\xf8H\x80\x84\x012\xb3\xa0\xa0\xcao\x0f\xbd\xed\xa8\x18!o9\x9c9]\xc8\x14\x12\x1ef\xbc\xa0\x13\x9c\xef%\xa2\xb8\x12#\xc48\xc1\xf6\xa0xRm\xcdfd\xf1x{\xca5'\x85\x8c\xdc\xfeQ+\x7f\x1f\xe1\xef>\xfb<8Z\x88\xc7\xe04\xe0", '*\xdc%fP\x18\xaa\x1f\xe0\xe6\xbcfm\xac\x8f\xc2i\x7f\xf9\xba': "\xf8G\x80\x83\x01\x1b\x10\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p", '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03': "\xf8D\x80\x80\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p"} | |
________________________________________________________ test_state[fixtures/StateTests/Homestead/stPreCompiledContracts.json-CallRipemd160_5-testdata3435] _________________________________________________________ | |
filename = 'fixtures/StateTests/Homestead/stPreCompiledContracts.json', testname = 'CallRipemd160_5' | |
testdata = {'env': {'currentCoinbase': '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba', 'currentDifficulty': '0x0100', 'currentGasLimi...e5edbc8e2a8697c15331677e6ebf0b': {'balance': '0x0de0b6b3a742c37c', 'code': '0x', 'nonce': '0x01', 'storage': {}}}, ...} | |
def test_state(filename, testname, testdata): | |
logger.debug('running test:%r in %r' % (testname, filename)) | |
> testutils.check_state_test(testutils.fixture_to_bytes(testdata)) | |
ethereum/tests/test_state.py:16: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
ethereum/testutils.py:51: in <lambda> | |
check_state_test = lambda params: run_state_test(params, VERIFY) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
params = {'env': {'currentCoinbase': '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba', 'currentDifficulty': '0x0100', 'currentGasLimi...e5edbc8e2a8697c15331677e6ebf0b': {'balance': '0x0de0b6b3a742c37c', 'code': '0x', 'nonce': '0x01', 'storage': {}}}, ...} | |
mode = 2 | |
def run_state_test(params, mode): | |
pre = params['pre'] | |
exek = params['transaction'] | |
env = params['env'] | |
assert set(env.keys()) == set(['currentGasLimit', 'currentTimestamp', | |
'previousHash', 'currentCoinbase', | |
'currentDifficulty', 'currentNumber']) | |
assert len(env['currentCoinbase']) == 40 | |
konfig = copy.deepcopy(default_config) | |
# konfig['HOMESTEAD_FORK_BLKNUM'] = 1000000 | |
state = State(env=Env(db, konfig), | |
prev_headers=[mk_fake_header(i) for i in range(parse_int_or_hex(env['currentNumber']) -1, max(-1, parse_int_or_hex(env['currentNumber']) -257), -1)], | |
block_number=parse_int_or_hex(env['currentNumber']), | |
block_coinbase=utils.normalize_address(env['currentCoinbase']), | |
timestamp=parse_int_or_hex(env['currentTimestamp']), | |
gas_limit=parse_int_or_hex(env['currentGasLimit']), | |
block_difficulty=parse_int_or_hex(env['currentDifficulty'])) | |
# setup state | |
for address, h in list(pre.items()): | |
assert len(address) == 40 | |
address = decode_hex(address) | |
assert set(h.keys()) == set(['code', 'nonce', 'balance', 'storage']) | |
state.set_nonce(address, parse_int_or_hex(h['nonce'])) | |
state.set_balance(address, parse_int_or_hex(h['balance'])) | |
state.set_code(address, decode_hex(h['code'][2:])) | |
for k, v in h['storage'].items(): | |
state.set_storage_data(address, | |
utils.big_endian_to_int(decode_hex(k[2:])), | |
decode_hex(v[2:])) | |
for address, h in list(pre.items()): | |
address = decode_hex(address) | |
assert state.get_nonce(address) == parse_int_or_hex(h['nonce']) | |
assert state.get_balance(address) == parse_int_or_hex(h['balance']) | |
assert state.get_code(address) == decode_hex(h['code'][2:]) | |
for k, v in h['storage'].items(): | |
assert state.get_storage_data(address, utils.big_endian_to_int( | |
decode_hex(k[2:]))) == utils.big_endian_to_int(decode_hex(v[2:])) | |
try: | |
tx = transactions.Transaction( | |
nonce=parse_int_or_hex(exek['nonce'] or b"0"), | |
gasprice=parse_int_or_hex(exek['gasPrice'] or b"0"), | |
startgas=parse_int_or_hex(exek['gasLimit'] or b"0"), | |
to=normalize_address(exek['to'], allow_blank=True), | |
value=parse_int_or_hex(exek['value'] or b"0"), | |
data=decode_hex(remove_0x_head(exek['data']))) | |
except InvalidTransaction: | |
tx = None | |
success, output = False, b'' | |
time_pre = time.time() | |
time_post = time_pre | |
state.commit(allow_empties=True) | |
else: | |
if 'secretKey' in exek: | |
tx.sign(exek['secretKey']) | |
elif all(key in exek for key in ['v', 'r', 's']): | |
tx.v = decode_hex(remove_0x_head(exek['v'])) | |
tx.r = decode_hex(remove_0x_head(exek['r'])) | |
tx.s = decode_hex(remove_0x_head(exek['s'])) | |
else: | |
assert False | |
time_pre = time.time() | |
state.commit(allow_empties=True) | |
snapshot = state.snapshot() | |
try: | |
print('trying') | |
success, output = state_transition.apply_transaction(state, tx) | |
logs = state.receipts[-1].logs | |
assert success | |
state.commit() | |
print('tx applied') | |
except InvalidTransaction: | |
success, output = False, b'' | |
state.commit() | |
pass | |
except AssertionError: | |
success, output = False, b'' | |
state.commit() | |
pass | |
time_post = time.time() | |
if tx.to == b'': | |
output = state.get_code(output) if output else b'' | |
params2 = copy.deepcopy(params) | |
if success: | |
params2['logs'] = [log.to_dict() for log in logs] | |
params2['out'] = '0x' + encode_hex(output) | |
params2['post'] = copy.deepcopy(state.to_dict()) | |
params2['postStateRoot'] = encode_hex(state.trie.root_hash) | |
if mode == FILL: | |
return params2 | |
elif mode == VERIFY: | |
params1 = copy.deepcopy(params) | |
shouldbe, reallyis = params1.get('post', None), params2.get('post', None) | |
compare_post_states(shouldbe, reallyis) | |
for k in ['pre', 'exec', 'env', 'callcreates', | |
'out', 'gas', 'logs', 'postStateRoot']: | |
_shouldbe = params1.get(k, None) | |
_reallyis = params2.get(k, None) | |
passed = False | |
if isinstance(_shouldbe, (str, bytes, unicode)) and _shouldbe[0] == '#': | |
if int(_shouldbe[1:]) == len(decode_hex(remove_0x_head(_reallyis))): | |
passed = True | |
if _shouldbe == _reallyis: | |
passed = True | |
if not passed: | |
print('s', shouldbe) | |
print('r', reallyis) | |
print(state.trie.to_dict()) | |
raise Exception("Mismatch: " + k + ':\n shouldbe %r\n reallyis %r' % | |
> (_shouldbe, _reallyis)) | |
E Exception: Mismatch: postStateRoot: | |
E shouldbe u'd2973c4abfcc5775a79c48621f1bcd0ebd72471853ba1d1c5116a423301db265' | |
E reallyis 'd89d14946c4b857d305d29221b4967867d49ea86124a2a9596fcb9a41597d751' | |
ethereum/testutils.py:409: Exception | |
----------------------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------------------ | |
trying | |
tx applied | |
('s', {u'a94f5374fce5edbc8e2a8697c15331677e6ebf0b': {u'nonce': u'0x01', u'balance': u'0x0de0b6b3a742c37c', u'storage': {}, u'code': u'0x'}, u'2adc25665018aa1fe0e6bc666dac8fc2697ff9ba': {u'nonce': u'0x00', u'balance': u'0x1fb5e4', u'storage': {}, u'code': u'0x'}, u'095e7baea6a6c7c4c2dfeb977efac326af552d87': {u'nonce': u'0x00', u'balance': u'0x0132b3a0', u'storage': {u'0x00': u'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}, u'code': u'0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60005260206000620f4240600060006003611770f1600255600051600055'}}) | |
('r', {'a94f5374fce5edbc8e2a8697c15331677e6ebf0b': {'nonce': '1', 'balance': '999999999997821820', 'storage': {}, 'code': '0x'}, '0000000000000000000000000000000000000003': {'nonce': '0', 'balance': '0', 'storage': {}, 'code': '0x'}, '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba': {'nonce': '0', 'balance': '2078180', 'storage': {}, 'code': '0x'}, '095e7baea6a6c7c4c2dfeb977efac326af552d87': {'nonce': '0', 'balance': '20100000', 'storage': {'00': 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}, 'code': '0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60005260206000620f4240600060006003611770f1600255600051600055'}}) | |
{'\xa9OSt\xfc\xe5\xed\xbc\x8e*\x86\x97\xc1S1g~n\xbf\x0b': "\xf8L\x01\x88\r\xe0\xb6\xb3\xa7B\xc3|\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p", '\t^{\xae\xa6\xa6\xc7\xc4\xc2\xdf\xeb\x97~\xfa\xc3&\xafU-\x87': "\xf8H\x80\x84\x012\xb3\xa0\xa0\xcao\x0f\xbd\xed\xa8\x18!o9\x9c9]\xc8\x14\x12\x1ef\xbc\xa0\x13\x9c\xef%\xa2\xb8\x12#\xc48\xc1\xf6\xa0\xcc%8\xbd\x04{\x07\xb8\xcal\xe6^\xe8r0\x19\xda\x92\x15\xe5\xb9'\x85\\\xd3J\xd9r\x81\xdfn\x1d", '*\xdc%fP\x18\xaa\x1f\xe0\xe6\xbcfm\xac\x8f\xc2i\x7f\xf9\xba': "\xf8G\x80\x83\x1f\xb5\xe4\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p", '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03': "\xf8D\x80\x80\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p"} | |
________________________________________________________ test_state[fixtures/StateTests/Homestead/stPreCompiledContracts.json-CallRipemd160_0-testdata3438] _________________________________________________________ | |
filename = 'fixtures/StateTests/Homestead/stPreCompiledContracts.json', testname = 'CallRipemd160_0' | |
testdata = {'env': {'currentCoinbase': '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba', 'currentDifficulty': '0x0100', 'currentGasLimi...e5edbc8e2a8697c15331677e6ebf0b': {'balance': '0x0de0b6b3a761763f', 'code': '0x', 'nonce': '0x01', 'storage': {}}}, ...} | |
def test_state(filename, testname, testdata): | |
logger.debug('running test:%r in %r' % (testname, filename)) | |
> testutils.check_state_test(testutils.fixture_to_bytes(testdata)) | |
ethereum/tests/test_state.py:16: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
ethereum/testutils.py:51: in <lambda> | |
check_state_test = lambda params: run_state_test(params, VERIFY) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
params = {'env': {'currentCoinbase': '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba', 'currentDifficulty': '0x0100', 'currentGasLimi...e5edbc8e2a8697c15331677e6ebf0b': {'balance': '0x0de0b6b3a761763f', 'code': '0x', 'nonce': '0x01', 'storage': {}}}, ...} | |
mode = 2 | |
def run_state_test(params, mode): | |
pre = params['pre'] | |
exek = params['transaction'] | |
env = params['env'] | |
assert set(env.keys()) == set(['currentGasLimit', 'currentTimestamp', | |
'previousHash', 'currentCoinbase', | |
'currentDifficulty', 'currentNumber']) | |
assert len(env['currentCoinbase']) == 40 | |
konfig = copy.deepcopy(default_config) | |
# konfig['HOMESTEAD_FORK_BLKNUM'] = 1000000 | |
state = State(env=Env(db, konfig), | |
prev_headers=[mk_fake_header(i) for i in range(parse_int_or_hex(env['currentNumber']) -1, max(-1, parse_int_or_hex(env['currentNumber']) -257), -1)], | |
block_number=parse_int_or_hex(env['currentNumber']), | |
block_coinbase=utils.normalize_address(env['currentCoinbase']), | |
timestamp=parse_int_or_hex(env['currentTimestamp']), | |
gas_limit=parse_int_or_hex(env['currentGasLimit']), | |
block_difficulty=parse_int_or_hex(env['currentDifficulty'])) | |
# setup state | |
for address, h in list(pre.items()): | |
assert len(address) == 40 | |
address = decode_hex(address) | |
assert set(h.keys()) == set(['code', 'nonce', 'balance', 'storage']) | |
state.set_nonce(address, parse_int_or_hex(h['nonce'])) | |
state.set_balance(address, parse_int_or_hex(h['balance'])) | |
state.set_code(address, decode_hex(h['code'][2:])) | |
for k, v in h['storage'].items(): | |
state.set_storage_data(address, | |
utils.big_endian_to_int(decode_hex(k[2:])), | |
decode_hex(v[2:])) | |
for address, h in list(pre.items()): | |
address = decode_hex(address) | |
assert state.get_nonce(address) == parse_int_or_hex(h['nonce']) | |
assert state.get_balance(address) == parse_int_or_hex(h['balance']) | |
assert state.get_code(address) == decode_hex(h['code'][2:]) | |
for k, v in h['storage'].items(): | |
assert state.get_storage_data(address, utils.big_endian_to_int( | |
decode_hex(k[2:]))) == utils.big_endian_to_int(decode_hex(v[2:])) | |
try: | |
tx = transactions.Transaction( | |
nonce=parse_int_or_hex(exek['nonce'] or b"0"), | |
gasprice=parse_int_or_hex(exek['gasPrice'] or b"0"), | |
startgas=parse_int_or_hex(exek['gasLimit'] or b"0"), | |
to=normalize_address(exek['to'], allow_blank=True), | |
value=parse_int_or_hex(exek['value'] or b"0"), | |
data=decode_hex(remove_0x_head(exek['data']))) | |
except InvalidTransaction: | |
tx = None | |
success, output = False, b'' | |
time_pre = time.time() | |
time_post = time_pre | |
state.commit(allow_empties=True) | |
else: | |
if 'secretKey' in exek: | |
tx.sign(exek['secretKey']) | |
elif all(key in exek for key in ['v', 'r', 's']): | |
tx.v = decode_hex(remove_0x_head(exek['v'])) | |
tx.r = decode_hex(remove_0x_head(exek['r'])) | |
tx.s = decode_hex(remove_0x_head(exek['s'])) | |
else: | |
assert False | |
time_pre = time.time() | |
state.commit(allow_empties=True) | |
snapshot = state.snapshot() | |
try: | |
print('trying') | |
success, output = state_transition.apply_transaction(state, tx) | |
logs = state.receipts[-1].logs | |
assert success | |
state.commit() | |
print('tx applied') | |
except InvalidTransaction: | |
success, output = False, b'' | |
state.commit() | |
pass | |
except AssertionError: | |
success, output = False, b'' | |
state.commit() | |
pass | |
time_post = time.time() | |
if tx.to == b'': | |
output = state.get_code(output) if output else b'' | |
params2 = copy.deepcopy(params) | |
if success: | |
params2['logs'] = [log.to_dict() for log in logs] | |
params2['out'] = '0x' + encode_hex(output) | |
params2['post'] = copy.deepcopy(state.to_dict()) | |
params2['postStateRoot'] = encode_hex(state.trie.root_hash) | |
if mode == FILL: | |
return params2 | |
elif mode == VERIFY: | |
params1 = copy.deepcopy(params) | |
shouldbe, reallyis = params1.get('post', None), params2.get('post', None) | |
compare_post_states(shouldbe, reallyis) | |
for k in ['pre', 'exec', 'env', 'callcreates', | |
'out', 'gas', 'logs', 'postStateRoot']: | |
_shouldbe = params1.get(k, None) | |
_reallyis = params2.get(k, None) | |
passed = False | |
if isinstance(_shouldbe, (str, bytes, unicode)) and _shouldbe[0] == '#': | |
if int(_shouldbe[1:]) == len(decode_hex(remove_0x_head(_reallyis))): | |
passed = True | |
if _shouldbe == _reallyis: | |
passed = True | |
if not passed: | |
print('s', shouldbe) | |
print('r', reallyis) | |
print(state.trie.to_dict()) | |
raise Exception("Mismatch: " + k + ':\n shouldbe %r\n reallyis %r' % | |
> (_shouldbe, _reallyis)) | |
E Exception: Mismatch: postStateRoot: | |
E shouldbe u'b418cef120df01a9cef80804c2f883527c0b550df6664166857a7c998a869b65' | |
E reallyis '84cbde9ca2ff822f260ba51a331096e5fcb4b0f1177712d177a52fc55e2d8e9c' | |
ethereum/testutils.py:409: Exception | |
----------------------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------------------ | |
trying | |
tx applied | |
('s', {u'a94f5374fce5edbc8e2a8697c15331677e6ebf0b': {u'nonce': u'0x01', u'balance': u'0x0de0b6b3a761763f', u'storage': {}, u'code': u'0x'}, u'2adc25665018aa1fe0e6bc666dac8fc2697ff9ba': {u'nonce': u'0x00', u'balance': u'0x010321', u'storage': {}, u'code': u'0x'}, u'095e7baea6a6c7c4c2dfeb977efac326af552d87': {u'nonce': u'0x00', u'balance': u'0x0132b3a0', u'storage': {u'0x00': u'0x01'}, u'code': u'0x600160005260206000602060006000600360fff1600051600055'}}) | |
('r', {'a94f5374fce5edbc8e2a8697c15331677e6ebf0b': {'nonce': '1', 'balance': '999999999999833663', 'storage': {}, 'code': '0x'}, '0000000000000000000000000000000000000003': {'nonce': '0', 'balance': '0', 'storage': {}, 'code': '0x'}, '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba': {'nonce': '0', 'balance': '66337', 'storage': {}, 'code': '0x'}, '095e7baea6a6c7c4c2dfeb977efac326af552d87': {'nonce': '0', 'balance': '20100000', 'storage': {'00': '01'}, 'code': '0x600160005260206000602060006000600360fff1600051600055'}}) | |
{'\xa9OSt\xfc\xe5\xed\xbc\x8e*\x86\x97\xc1S1g~n\xbf\x0b': "\xf8L\x01\x88\r\xe0\xb6\xb3\xa7av?\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p", '\t^{\xae\xa6\xa6\xc7\xc4\xc2\xdf\xeb\x97~\xfa\xc3&\xafU-\x87': '\xf8H\x80\x84\x012\xb3\xa0\xa0\x82\x1e%V\xa2\x90\xc8d\x05\xf8\x16\n-f B\xa41\xbaEk\x9d\xb2e\xc7\x9b\xb87\xc0K\xe5\xf0\xa0\xc0}E\x17\xa1\x10P\x95\x1d\x80\xd1_Q\x1a\x9bJ\x1a\xdc\xca\xba\xa5\xba\xd6\xa6\xb5Y\x9bd\xe3\x14K\xdf', '*\xdc%fP\x18\xaa\x1f\xe0\xe6\xbcfm\xac\x8f\xc2i\x7f\xf9\xba': "\xf8G\x80\x83\x01\x03!\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p", '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03': "\xf8D\x80\x80\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p"} | |
_____________________________________________________ test_state[fixtures/StateTests/Homestead/stPreCompiledContracts.json-CallRipemd160_4_gas719-testdata3455] _____________________________________________________ | |
filename = 'fixtures/StateTests/Homestead/stPreCompiledContracts.json', testname = 'CallRipemd160_4_gas719' | |
testdata = {'env': {'currentCoinbase': '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba', 'currentDifficulty': '0x0100', 'currentGasLimi...e5edbc8e2a8697c15331677e6ebf0b': {'balance': '0x0de0b6b3a76160e4', 'code': '0x', 'nonce': '0x01', 'storage': {}}}, ...} | |
def test_state(filename, testname, testdata): | |
logger.debug('running test:%r in %r' % (testname, filename)) | |
> testutils.check_state_test(testutils.fixture_to_bytes(testdata)) | |
ethereum/tests/test_state.py:16: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
ethereum/testutils.py:51: in <lambda> | |
check_state_test = lambda params: run_state_test(params, VERIFY) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
params = {'env': {'currentCoinbase': '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba', 'currentDifficulty': '0x0100', 'currentGasLimi...e5edbc8e2a8697c15331677e6ebf0b': {'balance': '0x0de0b6b3a76160e4', 'code': '0x', 'nonce': '0x01', 'storage': {}}}, ...} | |
mode = 2 | |
def run_state_test(params, mode): | |
pre = params['pre'] | |
exek = params['transaction'] | |
env = params['env'] | |
assert set(env.keys()) == set(['currentGasLimit', 'currentTimestamp', | |
'previousHash', 'currentCoinbase', | |
'currentDifficulty', 'currentNumber']) | |
assert len(env['currentCoinbase']) == 40 | |
konfig = copy.deepcopy(default_config) | |
# konfig['HOMESTEAD_FORK_BLKNUM'] = 1000000 | |
state = State(env=Env(db, konfig), | |
prev_headers=[mk_fake_header(i) for i in range(parse_int_or_hex(env['currentNumber']) -1, max(-1, parse_int_or_hex(env['currentNumber']) -257), -1)], | |
block_number=parse_int_or_hex(env['currentNumber']), | |
block_coinbase=utils.normalize_address(env['currentCoinbase']), | |
timestamp=parse_int_or_hex(env['currentTimestamp']), | |
gas_limit=parse_int_or_hex(env['currentGasLimit']), | |
block_difficulty=parse_int_or_hex(env['currentDifficulty'])) | |
# setup state | |
for address, h in list(pre.items()): | |
assert len(address) == 40 | |
address = decode_hex(address) | |
assert set(h.keys()) == set(['code', 'nonce', 'balance', 'storage']) | |
state.set_nonce(address, parse_int_or_hex(h['nonce'])) | |
state.set_balance(address, parse_int_or_hex(h['balance'])) | |
state.set_code(address, decode_hex(h['code'][2:])) | |
for k, v in h['storage'].items(): | |
state.set_storage_data(address, | |
utils.big_endian_to_int(decode_hex(k[2:])), | |
decode_hex(v[2:])) | |
for address, h in list(pre.items()): | |
address = decode_hex(address) | |
assert state.get_nonce(address) == parse_int_or_hex(h['nonce']) | |
assert state.get_balance(address) == parse_int_or_hex(h['balance']) | |
assert state.get_code(address) == decode_hex(h['code'][2:]) | |
for k, v in h['storage'].items(): | |
assert state.get_storage_data(address, utils.big_endian_to_int( | |
decode_hex(k[2:]))) == utils.big_endian_to_int(decode_hex(v[2:])) | |
try: | |
tx = transactions.Transaction( | |
nonce=parse_int_or_hex(exek['nonce'] or b"0"), | |
gasprice=parse_int_or_hex(exek['gasPrice'] or b"0"), | |
startgas=parse_int_or_hex(exek['gasLimit'] or b"0"), | |
to=normalize_address(exek['to'], allow_blank=True), | |
value=parse_int_or_hex(exek['value'] or b"0"), | |
data=decode_hex(remove_0x_head(exek['data']))) | |
except InvalidTransaction: | |
tx = None | |
success, output = False, b'' | |
time_pre = time.time() | |
time_post = time_pre | |
state.commit(allow_empties=True) | |
else: | |
if 'secretKey' in exek: | |
tx.sign(exek['secretKey']) | |
elif all(key in exek for key in ['v', 'r', 's']): | |
tx.v = decode_hex(remove_0x_head(exek['v'])) | |
tx.r = decode_hex(remove_0x_head(exek['r'])) | |
tx.s = decode_hex(remove_0x_head(exek['s'])) | |
else: | |
assert False | |
time_pre = time.time() | |
state.commit(allow_empties=True) | |
snapshot = state.snapshot() | |
try: | |
print('trying') | |
success, output = state_transition.apply_transaction(state, tx) | |
logs = state.receipts[-1].logs | |
assert success | |
state.commit() | |
print('tx applied') | |
except InvalidTransaction: | |
success, output = False, b'' | |
state.commit() | |
pass | |
except AssertionError: | |
success, output = False, b'' | |
state.commit() | |
pass | |
time_post = time.time() | |
if tx.to == b'': | |
output = state.get_code(output) if output else b'' | |
params2 = copy.deepcopy(params) | |
if success: | |
params2['logs'] = [log.to_dict() for log in logs] | |
params2['out'] = '0x' + encode_hex(output) | |
params2['post'] = copy.deepcopy(state.to_dict()) | |
params2['postStateRoot'] = encode_hex(state.trie.root_hash) | |
if mode == FILL: | |
return params2 | |
elif mode == VERIFY: | |
params1 = copy.deepcopy(params) | |
shouldbe, reallyis = params1.get('post', None), params2.get('post', None) | |
compare_post_states(shouldbe, reallyis) | |
for k in ['pre', 'exec', 'env', 'callcreates', | |
'out', 'gas', 'logs', 'postStateRoot']: | |
_shouldbe = params1.get(k, None) | |
_reallyis = params2.get(k, None) | |
passed = False | |
if isinstance(_shouldbe, (str, bytes, unicode)) and _shouldbe[0] == '#': | |
if int(_shouldbe[1:]) == len(decode_hex(remove_0x_head(_reallyis))): | |
passed = True | |
if _shouldbe == _reallyis: | |
passed = True | |
if not passed: | |
print('s', shouldbe) | |
print('r', reallyis) | |
print(state.trie.to_dict()) | |
raise Exception("Mismatch: " + k + ':\n shouldbe %r\n reallyis %r' % | |
> (_shouldbe, _reallyis)) | |
E Exception: Mismatch: postStateRoot: | |
E shouldbe u'1e83dde333b6e3f50223781c584bdc334145e3e58b0cea77c76e6247f2b58fa0' | |
E reallyis '6c90bbf3a4a4eac4f4741c311822048b3d786c40fa04c90fd25279fd26f4d01f' | |
ethereum/testutils.py:409: Exception | |
----------------------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------------------ | |
trying | |
tx applied | |
('s', {u'a94f5374fce5edbc8e2a8697c15331677e6ebf0b': {u'nonce': u'0x01', u'balance': u'0x0de0b6b3a76160e4', u'storage': {}, u'code': u'0x'}, u'2adc25665018aa1fe0e6bc666dac8fc2697ff9ba': {u'nonce': u'0x00', u'balance': u'0x01187c', u'storage': {}, u'code': u'0x'}, u'095e7baea6a6c7c4c2dfeb977efac326af552d87': {u'nonce': u'0x00', u'balance': u'0x0132b3a0', u'storage': {u'0x00': u'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}, u'code': u'0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000526020600060206000600060036102cff1600255600051600055'}}) | |
('r', {'a94f5374fce5edbc8e2a8697c15331677e6ebf0b': {'nonce': '1', 'balance': '999999999999828196', 'storage': {}, 'code': '0x'}, '0000000000000000000000000000000000000003': {'nonce': '0', 'balance': '0', 'storage': {}, 'code': '0x'}, '2adc25665018aa1fe0e6bc666dac8fc2697ff9ba': {'nonce': '0', 'balance': '71804', 'storage': {}, 'code': '0x'}, '095e7baea6a6c7c4c2dfeb977efac326af552d87': {'nonce': '0', 'balance': '20100000', 'storage': {'00': 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}, 'code': '0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000526020600060206000600060036102cff1600255600051600055'}}) | |
{'\xa9OSt\xfc\xe5\xed\xbc\x8e*\x86\x97\xc1S1g~n\xbf\x0b': "\xf8L\x01\x88\r\xe0\xb6\xb3\xa7a`\xe4\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p", '\t^{\xae\xa6\xa6\xc7\xc4\xc2\xdf\xeb\x97~\xfa\xc3&\xafU-\x87': "\xf8H\x80\x84\x012\xb3\xa0\xa0\xcao\x0f\xbd\xed\xa8\x18!o9\x9c9]\xc8\x14\x12\x1ef\xbc\xa0\x13\x9c\xef%\xa2\xb8\x12#\xc48\xc1\xf6\xa0xRm\xcdfd\xf1x{\xca5'\x85\x8c\xdc\xfeQ+\x7f\x1f\xe1\xef>\xfb<8Z\x88\xc7\xe04\xe0", '*\xdc%fP\x18\xaa\x1f\xe0\xe6\xbcfm\xac\x8f\xc2i\x7f\xf9\xba': "\xf8G\x80\x83\x01\x18|\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p", '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03': "\xf8D\x80\x80\xa0V\xe8\x1f\x17\x1b\xccU\xa6\xff\x83E\xe6\x92\xc0\xf8n[H\xe0\x1b\x99l\xad\xc0\x01b/\xb5\xe3c\xb4!\xa0\xc5\xd2F\x01\x86\xf7#<\x92~}\xb2\xdc\xc7\x03\xc0\xe5\x00\xb6S\xca\x82';{\xfa\xd8\x04]\x85\xa4p"} | |
========================================================================= 26 failed, 52825 passed, 99 skipped, 3 xfailed in 851.64 seconds ========================================================================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment