Skip to content

Commit f566236

Browse files
committed
spencer proposal: more tx type parametrizations
1 parent 2b3c6e6 commit f566236

File tree

4 files changed

+42
-57
lines changed

4 files changed

+42
-57
lines changed

tests/amsterdam/eip7981_increase_access_list_cost/conftest.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def authorization_list(
7272
request: pytest.FixtureRequest,
7373
pre: Alloc,
7474
authorization_refund: bool,
75-
ty: int,
75+
tx_type: int,
7676
) -> List[AuthorizationTuple] | None:
7777
"""
7878
Authorization-list for the transaction.
@@ -82,7 +82,7 @@ def authorization_list(
8282
parametrized value should be a list of addresses.
8383
"""
8484
if not hasattr(request, "param"):
85-
if ty == 4:
85+
if tx_type == 4:
8686
return [
8787
AuthorizationTuple(
8888
signer=pre.fund_eoa(1 if authorization_refund else 0),
@@ -91,7 +91,7 @@ def authorization_list(
9191
]
9292
return None
9393
if request.param is None:
94-
if ty == 4:
94+
if tx_type == 4:
9595
return [
9696
AuthorizationTuple(
9797
signer=pre.fund_eoa(1 if authorization_refund else 0),
@@ -109,14 +109,14 @@ def authorization_list(
109109

110110

111111
@pytest.fixture
112-
def blob_versioned_hashes(ty: int) -> Sequence[Hash] | None:
112+
def blob_versioned_hashes(tx_type: int) -> Sequence[Hash] | None:
113113
"""Versioned hashes for the transaction."""
114114
return (
115115
add_kzg_version(
116116
[Hash(1)],
117117
EIP_4844_Spec.BLOB_COMMITMENT_VERSION_KZG,
118118
)
119-
if ty == 3
119+
if tx_type == 3
120120
else None
121121
)
122122

@@ -260,7 +260,7 @@ def tx_error(
260260
@pytest.fixture
261261
def tx(
262262
sender: EOA,
263-
ty: int,
263+
tx_type: int,
264264
tx_data: Bytes,
265265
to: Address | None,
266266
protected: bool,
@@ -272,7 +272,7 @@ def tx(
272272
) -> Transaction:
273273
"""Create the transaction used in each test."""
274274
return Transaction(
275-
ty=ty,
275+
ty=tx_type,
276276
sender=sender,
277277
data=tx_data,
278278
to=to,

tests/amsterdam/eip7981_increase_access_list_cost/test_access_list_cost.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,17 @@
2222
pytestmark = pytest.mark.valid_at("Amsterdam")
2323

2424

25+
@pytest.mark.with_all_tx_types(selector=lambda tx_type: tx_type >= 1)
2526
@pytest.mark.parametrize(
26-
"ty,access_list,expected_tokens",
27+
"access_list,expected_tokens",
2728
[
2829
pytest.param(
29-
1,
3030
[AccessList(address=Address(0), storage_keys=[])],
3131
# 20 bytes, all zeros: 20 * 1 = 20 tokens
3232
20,
3333
id="single_zero_address_no_keys",
3434
),
3535
pytest.param(
36-
1,
3736
[
3837
AccessList(
3938
address=Address(
@@ -47,7 +46,6 @@
4746
id="single_nonzero_address_no_keys",
4847
),
4948
pytest.param(
50-
1,
5149
[AccessList(address=Address(0), storage_keys=[Hash(0)])],
5250
# Address: 20 zeros = 20 tokens
5351
# Storage key: 32 zeros = 32 tokens
@@ -56,7 +54,6 @@
5654
id="zero_address_zero_key",
5755
),
5856
pytest.param(
59-
1,
6057
[
6158
AccessList(
6259
address=Address(
@@ -76,7 +73,6 @@
7673
id="nonzero_address_nonzero_key",
7774
),
7875
pytest.param(
79-
1,
8076
[
8177
AccessList(
8278
address=Address(1),
@@ -92,7 +88,6 @@
9288
id="one_address_three_keys",
9389
),
9490
pytest.param(
95-
1,
9691
[
9792
AccessList(address=Address(1), storage_keys=[Hash(0)]),
9893
AccessList(address=Address(2), storage_keys=[Hash(1)]),
@@ -140,17 +135,16 @@ def test_access_list_token_calculation(
140135
)
141136

142137

138+
@pytest.mark.with_all_tx_types(selector=lambda tx_type: tx_type >= 1)
143139
@pytest.mark.parametrize(
144-
"ty,access_list,tx_data",
140+
"access_list,tx_data",
145141
[
146142
pytest.param(
147-
1,
148143
[AccessList(address=Address(1), storage_keys=[Hash(0)])],
149144
Bytes(b"\x01" * 100),
150145
id="access_list_and_calldata",
151146
),
152147
pytest.param(
153-
1,
154148
[
155149
AccessList(
156150
address=Address(1),
@@ -187,11 +181,11 @@ def test_access_list_floor_cost_with_calldata(
187181
)
188182

189183

184+
@pytest.mark.with_all_tx_types(selector=lambda tx_type: tx_type >= 1)
190185
@pytest.mark.parametrize(
191-
"ty,access_list",
186+
"access_list",
192187
[
193188
pytest.param(
194-
1,
195189
[
196190
AccessList(
197191
address=Address(i),
@@ -227,11 +221,11 @@ def test_large_access_list_cost(
227221
)
228222

229223

224+
@pytest.mark.with_all_tx_types(selector=lambda tx_type: tx_type >= 1)
230225
@pytest.mark.parametrize(
231-
"ty,access_list",
226+
"access_list",
232227
[
233228
pytest.param(
234-
1,
235229
[
236230
AccessList(address=Address(1), storage_keys=[Hash(0)]),
237231
AccessList(address=Address(1), storage_keys=[Hash(0)]),

tests/amsterdam/eip7981_increase_access_list_cost/test_eip_mainnet.py

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,31 @@
2020
pytestmark = [pytest.mark.valid_at("Amsterdam"), pytest.mark.mainnet]
2121

2222

23+
@pytest.mark.with_all_tx_types(selector=lambda tx_type: tx_type >= 1)
2324
@pytest.mark.parametrize(
24-
"ty,access_list",
25+
"access_list",
2526
[
2627
pytest.param(
27-
1,
2828
[AccessList(address=Address(1), storage_keys=[Hash(0)])],
29-
id="type_1_single_address_single_key",
29+
id="single_address_single_key",
3030
),
3131
pytest.param(
32-
1,
3332
[
3433
AccessList(
3534
address=Address(1),
3635
storage_keys=[Hash(0), Hash(1), Hash(2)],
3736
)
3837
],
39-
id="type_1_single_address_multiple_keys",
38+
id="single_address_multiple_keys",
4039
),
4140
pytest.param(
42-
1,
4341
[
4442
AccessList(address=Address(1), storage_keys=[Hash(0)]),
4543
AccessList(address=Address(2), storage_keys=[Hash(1)]),
4644
],
47-
id="type_1_multiple_addresses",
45+
id="multiple_addresses",
4846
),
4947
pytest.param(
50-
1,
5148
[
5249
AccessList(
5350
address=Address(
@@ -63,17 +60,7 @@
6360
],
6461
)
6562
],
66-
id="type_1_realistic_address_and_keys",
67-
),
68-
pytest.param(
69-
2,
70-
[AccessList(address=Address(1), storage_keys=[Hash(0)])],
71-
id="type_2_single_address_single_key",
72-
),
73-
pytest.param(
74-
4,
75-
[AccessList(address=Address(1), storage_keys=[Hash(0)])],
76-
id="type_4_single_address_single_key",
63+
id="realistic_address_and_keys",
7764
),
7865
],
7966
)
@@ -105,11 +92,11 @@ def test_access_list_gas_cost(
10592
)
10693

10794

95+
@pytest.mark.with_all_tx_types(selector=lambda tx_type: tx_type >= 1)
10896
@pytest.mark.parametrize(
109-
"ty,access_list",
97+
"access_list",
11098
[
11199
pytest.param(
112-
1,
113100
[
114101
AccessList(
115102
address=Address(0),
@@ -119,7 +106,6 @@ def test_access_list_gas_cost(
119106
id="all_zero_bytes",
120107
),
121108
pytest.param(
122-
1,
123109
[
124110
AccessList(
125111
address=Address(

tests/amsterdam/eip7981_increase_access_list_cost/test_transaction_validity.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,21 @@
2222

2323

2424
@pytest.mark.exception_test
25+
@pytest.mark.with_all_tx_types(selector=lambda tx_type: tx_type >= 1)
2526
@pytest.mark.parametrize(
26-
"ty,access_list,tx_gas_delta",
27+
"access_list,tx_gas_delta",
2728
[
2829
pytest.param(
29-
1,
3030
[AccessList(address=Address(1), storage_keys=[Hash(0)])],
3131
-1,
3232
id="insufficient_gas_by_one",
3333
),
3434
pytest.param(
35-
1,
3635
[AccessList(address=Address(1), storage_keys=[Hash(0)])],
3736
-100,
3837
id="insufficient_gas_by_hundred",
3938
),
4039
pytest.param(
41-
1,
4240
[
4341
AccessList(
4442
address=Address(1),
@@ -79,11 +77,11 @@ def test_insufficient_gas_for_access_list(
7977

8078

8179
@pytest.mark.exception_test
80+
@pytest.mark.with_all_tx_types(selector=lambda tx_type: tx_type >= 1)
8281
@pytest.mark.parametrize(
83-
"ty,access_list,tx_data,tx_gas_delta",
82+
"access_list,tx_data,tx_gas_delta",
8483
[
8584
pytest.param(
86-
1,
8785
[AccessList(address=Address(1), storage_keys=[Hash(0)])],
8886
Bytes(b"\x01" * 1000),
8987
-1,
@@ -117,23 +115,21 @@ def test_floor_cost_validation_with_access_list(
117115
)
118116

119117

118+
@pytest.mark.with_all_tx_types(selector=lambda tx_type: tx_type >= 1)
120119
@pytest.mark.parametrize(
121-
"ty,access_list,tx_gas_delta",
120+
"access_list,tx_gas_delta",
122121
[
123122
pytest.param(
124-
1,
125123
[AccessList(address=Address(1), storage_keys=[Hash(0)])],
126124
0,
127125
id="exact_gas",
128126
),
129127
pytest.param(
130-
1,
131128
[AccessList(address=Address(1), storage_keys=[Hash(0)])],
132129
1,
133130
id="one_extra_gas",
134131
),
135132
pytest.param(
136-
1,
137133
[AccessList(address=Address(1), storage_keys=[Hash(0)])],
138134
1000,
139135
id="plenty_extra_gas",
@@ -165,17 +161,16 @@ def test_valid_gas_limits_with_access_list(
165161
)
166162

167163

164+
@pytest.mark.with_all_tx_types(selector=lambda tx_type: tx_type >= 1)
168165
@pytest.mark.parametrize(
169-
"ty,access_list,tx_data",
166+
"access_list,tx_data",
170167
[
171168
pytest.param(
172-
1,
173169
[AccessList(address=Address(0), storage_keys=[Hash(0)] * 100)],
174170
Bytes(b"\x00" * 1000),
175171
id="zero_heavy_data_and_access_list",
176172
),
177173
pytest.param(
178-
1,
179174
[
180175
AccessList(
181176
address=Address(
@@ -223,7 +218,7 @@ def test_mixed_zero_nonzero_bytes_floor_cost(
223218

224219

225220
@pytest.mark.parametrize(
226-
"ty,access_list",
221+
"tx_type,access_list",
227222
[
228223
pytest.param(
229224
0,
@@ -240,6 +235,16 @@ def test_mixed_zero_nonzero_bytes_floor_cost(
240235
[],
241236
id="type_2_empty_access_list",
242237
),
238+
pytest.param(
239+
3,
240+
[],
241+
id="type_3_empty_access_list",
242+
),
243+
pytest.param(
244+
4,
245+
[],
246+
id="type_4_empty_access_list",
247+
),
243248
],
244249
)
245250
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)