Skip to content

Commit 823718a

Browse files
marioevzspencer-tb
andauthored
new(tests): EIP-7702: Delegation Designation as Initcode, max-fee-per-gas tests (#1372)
* new(tests): EIP-7702: Delegation designation as initcode * new(tests): EIP-7702: Invalid max_fee_per_gas/max_priority_fee_per_gas * docs: changelog * refactor(tests): Combine similar cases into one Co-Authored-By: spencer <[email protected]> --------- Co-authored-by: spencer <[email protected]>
1 parent db9f3c3 commit 823718a

File tree

2 files changed

+76
-3
lines changed

2 files changed

+76
-3
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ consume cache --help
6767
- ✨ Add additional test coverage for EIP-152 Blake2 precompiles ([#1244](https://github.com/ethereum/execution-spec-tests/pull/1244)). Refactor to add variables for spec constants and common fixture code. ([#1395](https://github.com/ethereum/execution-spec-tests/pull/1395)).
6868
- ✨ Add EIP-7702 incorrect-rlp-encoding tests ([#1347](https://github.com/ethereum/execution-spec-tests/pull/1347)).
6969
- ✨ Add EIP-2935 tests for all call opcodes ([#1379](https://github.com/ethereum/execution-spec-tests/pull/1379)).
70+
- ✨ Add more tests for EIP-7702: max-fee-per-gas verification, delegation-designation as initcode tests ([#1372](https://github.com/ethereum/execution-spec-tests/pull/1372)).
7071

7172
## [v4.1.0](https://github.com/ethereum/execution-spec-tests/releases/tag/v4.1.0) - 2025-03-11
7273

tests/prague/eip7702_set_code_tx/test_set_code_txs.py

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3230,9 +3230,17 @@ def test_delegation_clearing_failing_tx(
32303230
)
32313231

32323232

3233+
@pytest.mark.parametrize(
3234+
"initcode_is_delegation_designation",
3235+
[
3236+
pytest.param(True, id="initcode_deploys_delegation_designation"),
3237+
pytest.param(False, id="initcode_is_delegation_designation"),
3238+
],
3239+
)
32333240
def test_deploying_delegation_designation_contract(
32343241
state_test: StateTestFiller,
32353242
pre: Alloc,
3243+
initcode_is_delegation_designation: bool,
32363244
):
32373245
"""
32383246
Test attempting to deploy a contract that has the same format as a
@@ -3243,7 +3251,11 @@ def test_deploying_delegation_designation_contract(
32433251
set_to_code = Op.RETURN(0, 1)
32443252
set_to_address = pre.deploy_contract(set_to_code)
32453253

3246-
initcode = Initcode(deploy_code=Spec.delegation_designation(set_to_address))
3254+
initcode: Bytes | Bytecode
3255+
if initcode_is_delegation_designation:
3256+
initcode = Spec.delegation_designation(set_to_address)
3257+
else:
3258+
initcode = Initcode(deploy_code=Spec.delegation_designation(set_to_address))
32473259

32483260
tx = Transaction(
32493261
sender=sender,
@@ -3265,9 +3277,19 @@ def test_deploying_delegation_designation_contract(
32653277
)
32663278

32673279

3280+
@pytest.mark.parametrize(
3281+
"initcode_is_delegation_designation",
3282+
[
3283+
pytest.param(True, id="initcode_deploys_delegation_designation"),
3284+
pytest.param(False, id="initcode_is_delegation_designation"),
3285+
],
3286+
)
32683287
@pytest.mark.parametrize("create_opcode", [Op.CREATE, Op.CREATE2])
32693288
def test_creating_delegation_designation_contract(
3270-
state_test: StateTestFiller, pre: Alloc, create_opcode: Op
3289+
state_test: StateTestFiller,
3290+
pre: Alloc,
3291+
create_opcode: Op,
3292+
initcode_is_delegation_designation: bool,
32713293
):
32723294
"""
32733295
Tx -> create -> pointer bytecode
@@ -3282,7 +3304,11 @@ def test_creating_delegation_designation_contract(
32823304
# An attempt to deploy code starting with ef01 result in no
32833305
# contract being created as it is prohibited
32843306

3285-
create_init = Initcode(deploy_code=Spec.delegation_designation(sender))
3307+
create_init: Bytes | Bytecode
3308+
if initcode_is_delegation_designation:
3309+
create_init = Spec.delegation_designation(sender)
3310+
else:
3311+
create_init = Initcode(deploy_code=Spec.delegation_designation(sender))
32863312
contract_a = pre.deploy_contract(
32873313
balance=100,
32883314
code=Op.MSTORE(0, Op.CALLDATALOAD(0))
@@ -3565,3 +3591,49 @@ def test_set_code_from_account_with_non_delegating_code(
35653591
callee_address: Account(storage={0: 0}),
35663592
},
35673593
)
3594+
3595+
3596+
@pytest.mark.parametrize(
3597+
"max_fee_per_gas, max_priority_fee_per_gas, expected_error",
3598+
[
3599+
(6, 0, TransactionException.INSUFFICIENT_MAX_FEE_PER_GAS),
3600+
(7, 8, TransactionException.PRIORITY_GREATER_THAN_MAX_FEE_PER_GAS),
3601+
],
3602+
ids=[
3603+
"insufficient_max_fee_per_gas",
3604+
"priority_greater_than_max_fee_per_gas",
3605+
],
3606+
)
3607+
def test_set_code_transaction_fee_validations(
3608+
state_test: StateTestFiller,
3609+
pre: Alloc,
3610+
max_fee_per_gas: int,
3611+
max_priority_fee_per_gas: int,
3612+
expected_error: TransactionException,
3613+
):
3614+
"""Test that a transaction with an insufficient max fee per gas is rejected."""
3615+
set_to_code = pre.deploy_contract(Op.STOP)
3616+
auth_signer = pre.fund_eoa(amount=0)
3617+
tx = Transaction(
3618+
sender=pre.fund_eoa(),
3619+
gas_limit=500_000,
3620+
to=auth_signer,
3621+
value=0,
3622+
max_fee_per_gas=max_fee_per_gas,
3623+
max_priority_fee_per_gas=max_priority_fee_per_gas,
3624+
authorization_list=[
3625+
AuthorizationTuple(
3626+
address=set_to_code,
3627+
nonce=0,
3628+
signer=auth_signer,
3629+
),
3630+
],
3631+
error=expected_error,
3632+
)
3633+
3634+
state_test(
3635+
env=Environment(),
3636+
pre=pre,
3637+
tx=tx,
3638+
post={},
3639+
)

0 commit comments

Comments
 (0)