test_extcodehash_of_empty()
Documentation for tests/constantinople/eip1052_extcodehash/test_extcodehash.py::test_extcodehash_of_empty@b314d18e.
Generate fixtures for these test cases for Amsterdam with:
fill -v tests/constantinople/eip1052_extcodehash/test_extcodehash.py::test_extcodehash_of_empty --fork Amsterdam
Test EXTCODEHASH/EXTCODESIZE for non-existent and empty accounts.
Source code in tests/constantinople/eip1052_extcodehash/test_extcodehash.py
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109 | @pytest.mark.ported_from(
[
"https://github.com/ethereum/tests/blob/v13.3/src/GeneralStateTestsFiller/stExtCodeHash/extCodeHashNonExistingAccountFiller.yml", # noqa: E501
"https://github.com/ethereum/tests/blob/v13.3/src/GeneralStateTestsFiller/stExtCodeHash/extCodeHashAccountWithoutCodeFiller.yml", # noqa: E501
],
pr=["https://github.com/ethereum/execution-specs/pull/2237"],
)
@pytest.mark.parametrize("target_exists", [True, False])
def test_extcodehash_of_empty(
state_test: StateTestFiller,
pre: Alloc,
target_exists: bool,
) -> None:
"""
Test EXTCODEHASH/EXTCODESIZE for non-existent and empty accounts.
"""
storage = Storage()
target_address = pre.nonexistent_account()
if target_exists:
pre.fund_address(target_address, 1)
expected_hash = keccak256(b"") if target_exists else 0
code = Op.SSTORE(
storage.store_next(expected_hash),
Op.EXTCODEHASH(target_address),
) + Op.SSTORE(
storage.store_next(0),
Op.EXTCODESIZE(target_address),
)
code_address = pre.deploy_contract(code, storage=storage.canary())
tx = Transaction(sender=pre.fund_eoa(), to=code_address, value=1)
state_test(
pre=pre,
post={
code_address: Account(storage=storage),
},
tx=tx,
)
|
Parametrized Test Cases
This test generates 2 parametrized test cases across 10 forks.