Skip to content

Commit 4eabd77

Browse files
winsvegamarioevz
andauthored
feat(tests): EIP-7702: test set code tx ideas implementation (ethereum#981)
* test set code tx ideas * address comments * changelog * 7702 gas measure * make black happy * storage modifications, static context * clarify gas prices * reentrancy test * revert scenarios * suicide a pointer that points to newly created account * fix Ruff * apply suggestions * Update tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py --------- Co-authored-by: Mario Vega <[email protected]>
1 parent 54526b8 commit 4eabd77

File tree

2 files changed

+1739
-0
lines changed

2 files changed

+1739
-0
lines changed

prague/eip7702_set_code_tx/test_set_code_txs.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3237,6 +3237,52 @@ def test_deploying_delegation_designation_contract(
32373237
)
32383238

32393239

3240+
@pytest.mark.parametrize("create_opcode", [Op.CREATE, Op.CREATE2])
3241+
def test_creating_delegation_designation_contract(
3242+
state_test: StateTestFiller, pre: Alloc, create_opcode: Op
3243+
):
3244+
"""
3245+
Tx -> create -> pointer bytecode
3246+
Attempt to deploy contract with magic bytes result in no contract being created.
3247+
"""
3248+
env = Environment()
3249+
3250+
storage: Storage = Storage()
3251+
3252+
sender = pre.fund_eoa()
3253+
3254+
# An attempt to deploy code starting with ef01 result in no
3255+
# contract being created as it is prohibited
3256+
3257+
create_init = Initcode(deploy_code=Spec.delegation_designation(sender))
3258+
contract_a = pre.deploy_contract(
3259+
balance=100,
3260+
code=Op.MSTORE(0, Op.CALLDATALOAD(0))
3261+
+ Op.SSTORE(
3262+
storage.store_next(0, "contract_a_create_result"),
3263+
create_opcode(value=1, offset=0, size=Op.CALLDATASIZE(), salt=0),
3264+
)
3265+
+ Op.STOP,
3266+
)
3267+
3268+
tx = Transaction(
3269+
to=contract_a,
3270+
gas_limit=1_000_000,
3271+
data=create_init,
3272+
value=0,
3273+
sender=sender,
3274+
)
3275+
3276+
create_address = compute_create_address(
3277+
address=contract_a, nonce=1, initcode=create_init, salt=0, opcode=create_opcode
3278+
)
3279+
post = {
3280+
contract_a: Account(balance=100, storage=storage),
3281+
create_address: Account.NONEXISTENT,
3282+
}
3283+
state_test(env=env, pre=pre, post=post, tx=tx)
3284+
3285+
32403286
@pytest.mark.parametrize(
32413287
"signer_balance",
32423288
[

0 commit comments

Comments
 (0)