Skip to content

Commit a204ab9

Browse files
authored
new(tests): DATALOADN with truncated immediate bytes (#1127)
1 parent 5a195ee commit a204ab9

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

converted-ethereum-tests.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ EOFTests/efValidation/callf_into_nonreturning_.json
1818
EOFTests/efValidation/EOF1_embedded_container_.json
1919
EOFTests/efValidation/EOF1_eofcreate_valid_.json
2020
EOFTests/efValidation/EOF1_callf_truncated_.json
21+
EOFTests/efValidation/EOF1_dataloadn_truncated_.json
2122
EOFTests/efValidation/EOF1_valid_rjump_.json
2223
EOFTests/efValidation/EOF1_valid_rjumpi_.json
2324
EOFTests/efValidation/EOF1_valid_rjumpv_.json

tests/osaka/eip7692_eof_v1/eip4750_functions/test_code_validation.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ def test_eof_validity(
185185
code=Op.CALLF,
186186
)
187187
],
188-
validity_error=EOFException.TRUNCATED_INSTRUCTION,
189188
),
190189
Container(
191190
name="imm1",
@@ -194,7 +193,6 @@ def test_eof_validity(
194193
code=Op.CALLF + Op.STOP,
195194
)
196195
],
197-
validity_error=EOFException.TRUNCATED_INSTRUCTION,
198196
),
199197
Container(
200198
name="imm_from_next_section",
@@ -215,7 +213,6 @@ def test_eof_validity(
215213
max_stack_height=2,
216214
),
217215
],
218-
validity_error=EOFException.TRUNCATED_INSTRUCTION,
219216
),
220217
],
221218
ids=container_name,

tests/osaka/eip7692_eof_v1/eip7480_data_section/test_code_validation.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,48 @@ def test_legacy_initcode_invalid_eof_v1_contract(
177177
data=container,
178178
expect_exception=container.validity_error,
179179
)
180+
181+
182+
@pytest.mark.parametrize(
183+
"container",
184+
[
185+
Container(
186+
name="imm0",
187+
sections=[
188+
Section.Code(Op.DATALOADN),
189+
Section.Data(b"\xff" * 32),
190+
],
191+
),
192+
Container(
193+
name="imm1",
194+
sections=[
195+
Section.Code(Op.DATALOADN + Op.STOP),
196+
Section.Data(b"\xff" * 32),
197+
],
198+
),
199+
Container(
200+
name="imm_from_next_section",
201+
sections=[
202+
Section.Code(
203+
Op.CALLF[1] + Op.JUMPF[2],
204+
max_stack_height=1,
205+
),
206+
Section.Code(
207+
Op.DATALOADN + Op.STOP,
208+
code_outputs=1,
209+
),
210+
Section.Code(
211+
Op.STOP,
212+
),
213+
Section.Data(b"\xff" * 32),
214+
],
215+
),
216+
],
217+
ids=container_name,
218+
)
219+
def test_dataloadn_truncated_immediate(
220+
eof_test: EOFTestFiller,
221+
container: Container,
222+
):
223+
"""Test cases for DATALOADN instructions with truncated immediate bytes."""
224+
eof_test(data=container, expect_exception=EOFException.TRUNCATED_INSTRUCTION)

tests/osaka/eip7692_eof_v1/eof_tracker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@
354354
### Validation
355355

356356
- [ ] Valid DATALOADN with various offsets (ethereum/tests: src/EOFTestsFiller/efValidation/dataloadn_Copier.json)
357-
- [ ] Truncated DATALOADN immediate (ethereum/tests: ./src/EOFTestsFiller/efValidation/EOF1_dataloadn_truncated_Copier.json)
357+
- [x] Truncated DATALOADN immediate ([`tests/osaka/eip7692_eof_v1/eip7480_data_section/test_code_validation.py::test_dataloadn_truncated_immediate`](./eip7480_data_section/test_code_validation/test_dataloadn_truncated_immediate.md)
358358
- [ ] DATALOADN offset out of bounds (ethereum/tests: src/EOFTestsFiller/efValidation/dataloadn_Copier.json)
359359
- [ ] DATALOADN accessing not full word (ethereum/tests: src/EOFTestsFiller/efValidation/dataloadn_Copier.json)
360360

0 commit comments

Comments
 (0)