Skip to content

Commit e70d831

Browse files
committed
fix(tests): EIP-7702 invalid tx on invalid signatures
1 parent b6a9f6b commit e70d831

File tree

1 file changed

+79
-17
lines changed

1 file changed

+79
-17
lines changed

tests/prague/eip7702_set_code_tx/test_set_code_txs.py

Lines changed: 79 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,44 +2039,106 @@ def test_set_code_using_valid_synthetic_signatures(
20392039
@pytest.mark.parametrize(
20402040
"v,r,s",
20412041
[
2042-
pytest.param(2, 1, 1, id="v=2,r=1,s=1"),
2043-
pytest.param(1, 0, 1, id="v=1,r=0,s=1"),
2044-
pytest.param(1, 1, 0, id="v=1,r=1,s=0"),
2042+
pytest.param(2, 1, 1, id="v_2,r_1,s_1"),
20452043
pytest.param(
20462044
0,
2047-
SECP256K1N,
20482045
1,
2049-
id="v=0,r=SECP256K1N,s=1",
2046+
SECP256K1N_OVER_2 + 1,
2047+
id="v_0,r_1,s_SECP256K1N_OVER_2+1",
2048+
),
2049+
pytest.param(
2050+
2**256 - 1,
2051+
1,
2052+
1,
2053+
id="v_2**256-1,r_1,s_1",
20502054
),
20512055
pytest.param(
20522056
0,
2053-
SECP256K1N - 1,
20542057
1,
2055-
id="v=0,r=SECP256K1N-1,s=1",
2058+
2**256 - 1,
2059+
id="v_0,r_1,s_2**256-1",
20562060
),
2061+
],
2062+
)
2063+
def test_invalid_tx_invalid_auth_signature(
2064+
state_test: StateTestFiller,
2065+
pre: Alloc,
2066+
v: int,
2067+
r: int,
2068+
s: int,
2069+
):
2070+
"""
2071+
Test sending a transaction to set the code of an account using synthetic signatures.
2072+
"""
2073+
success_slot = 1
2074+
2075+
callee_code = Op.SSTORE(success_slot, 1) + Op.STOP
2076+
callee_address = pre.deploy_contract(callee_code)
2077+
2078+
authorization_tuple = AuthorizationTuple(
2079+
address=0,
2080+
nonce=0,
2081+
chain_id=1,
2082+
v=v,
2083+
r=r,
2084+
s=s,
2085+
)
2086+
2087+
tx = Transaction(
2088+
gas_limit=100_000,
2089+
to=callee_address,
2090+
value=0,
2091+
authorization_list=[authorization_tuple],
2092+
error=TransactionException.TYPE_4_INVALID_AUTHORITY_SIGNATURE,
2093+
sender=pre.fund_eoa(),
2094+
)
2095+
2096+
state_test(
2097+
env=Environment(),
2098+
pre=pre,
2099+
tx=tx,
2100+
post={
2101+
callee_address: Account(
2102+
storage={success_slot: 0},
2103+
),
2104+
},
2105+
)
2106+
2107+
2108+
@pytest.mark.parametrize(
2109+
"v,r,s",
2110+
[
2111+
pytest.param(1, 0, 1, id="v_1,r_0,s_1"),
2112+
pytest.param(1, 1, 0, id="v_1,r_1,s_0"),
20572113
pytest.param(
20582114
0,
2115+
SECP256K1N,
20592116
1,
2060-
SECP256K1N_OVER_2 + 1,
2061-
id="v=0,r=1,s=SECP256K1N_OVER_2+1",
2117+
id="v_0,r_SECP256K1N,s_1",
20622118
),
20632119
pytest.param(
2064-
2**256 - 1,
2120+
0,
2121+
SECP256K1N - 1,
20652122
1,
2123+
id="v_0,r_SECP256K1N-1,s_1",
2124+
),
2125+
pytest.param(
2126+
0,
20662127
1,
2067-
id="v=2**256-1,r=1,s=1",
2128+
SECP256K1N_OVER_2,
2129+
id="v_0,r_1,s_SECP256K1N_OVER_2",
20682130
),
20692131
pytest.param(
20702132
0,
20712133
1,
2072-
2**256 - 1,
2073-
id="v=0,r=1,s=2**256-1",
2134+
SECP256K1N_OVER_2 - 1,
2135+
id="v_0,r_1,s_SECP256K1N_OVER_2_minus_one",
20742136
),
20752137
pytest.param(
20762138
1,
20772139
2**256 - 1,
20782140
1,
2079-
id="v=1,r=2**256-1,s=1",
2141+
id="v_1,r_2**256-1,s_1",
20802142
),
20812143
],
20822144
)
@@ -2088,7 +2150,8 @@ def test_set_code_using_invalid_signatures(
20882150
s: int,
20892151
):
20902152
"""
2091-
Test sending a transaction to set the code of an account using synthetic signatures.
2153+
Test sending a transaction to set the code of an account using synthetic signatures,
2154+
the transaction is valid but the authorization should not go through.
20922155
"""
20932156
success_slot = 1
20942157

@@ -2109,7 +2172,6 @@ def test_set_code_using_invalid_signatures(
21092172
to=callee_address,
21102173
value=0,
21112174
authorization_list=[authorization_tuple],
2112-
error=TransactionException.TYPE_4_INVALID_AUTHORITY_SIGNATURE,
21132175
sender=pre.fund_eoa(),
21142176
)
21152177

@@ -2119,7 +2181,7 @@ def test_set_code_using_invalid_signatures(
21192181
tx=tx,
21202182
post={
21212183
callee_address: Account(
2122-
storage={success_slot: 0},
2184+
storage={success_slot: 1},
21232185
),
21242186
},
21252187
)

0 commit comments

Comments
 (0)