Skip to content

Commit

Permalink
Add DATACOPY edge cases for common int sizes
Browse files Browse the repository at this point in the history
Add tests for the DATACOPY data offset, to check for cases where
trimming the u256 to a more developer friendly size (u64 / long for
example) results in erroneous indexes into the data section.

Signed-off-by: Danno Ferrin <[email protected]>
  • Loading branch information
shemnon committed Dec 13, 2024
1 parent dc05b42 commit 7e2532f
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def create_data_test(offset: int, datasize: int):
),
),
Section.Code(
code=(Op.PUSH2(offset) + Op.DATALOAD + Op.PUSH1(1) + Op.SSTORE + Op.RETF),
code=(Op.DATALOAD(offset) + Op.PUSH1(1) + Op.SSTORE + Op.RETF),
code_inputs=0,
code_outputs=0,
),
Expand Down Expand Up @@ -81,6 +81,12 @@ def create_data_test(offset: int, datasize: int):
pytest.param(0x5BFE, 0x5C00, id="short_23k"),
pytest.param(0x5BE0, 0x5D00, id="exact_23k"),
pytest.param(0x2345, 0x5C00, id="large_23k"),
pytest.param(2**16-1, 32, id="u16_max"),
pytest.param(2**16, 32, id="u16_max_plus_1"),
pytest.param(2**32-1, 32, id="u32_max"),
pytest.param(2**32, 32, id="u32_max_plus_1"),
pytest.param(2**64-1, 32, id="u64_max"),
pytest.param(2**64, 32, id="u64_max_plus_1"),
],
)
def test_data_section_succeed(
Expand Down

0 comments on commit 7e2532f

Please sign in to comment.