Skip to content

test_valid_mcopy_operations()

Documentation for tests/cancun/eip5656_mcopy/test_mcopy.py::test_valid_mcopy_operations@ffe48572.

Generate fixtures for these test cases for Bogota with:

fill -v tests/cancun/eip5656_mcopy/test_mcopy.py::test_valid_mcopy_operations --fork Bogota

Perform MCOPY operations using different offsets and lengths.

  • Zero inputs
  • Memory rewrites (copy from and to the same location)
  • Memory overwrites (copy from and to different locations)
  • Memory extensions (copy to a location that is out of bounds)
  • Memory clear (copy from a location that is out of bounds).
Source code in tests/cancun/eip5656_mcopy/test_mcopy.py
@pytest.mark.parametrize(
    "dest,src,length",
    [
        (0x00, 0x00, 0x00),
        (2**256 - 1, 0x00, 0x00),
        (0x00, 0x00, 0x01),
        (0x00, 0x00, 0x20),
        (0x01, 0x00, 0x01),
        (0x01, 0x00, 0x20),
        (0x11, 0x11, 0x01),
        (0x11, 0x11, 0x20),
        (0x11, 0x11, 0x40),
        (0x10, 0x00, 0x40),
        (0x00, 0x10, 0x40),
        (0x0F, 0x10, 0x40),
        (0x100, 0x01, 0x01),
        (0x100, 0x01, 0x20),
        (0x100, 0x01, 0x1F),
        (0x100, 0x01, 0x21),
        (0x00, 0x00, 0x100),
        (0x100, 0x00, 0x100),
        (0x200, 0x00, 0x100),
        (0x00, 0x100, 0x100),
        (0x100, 0x100, 0x01),
    ],
    ids=[
        "zero_inputs",
        "zero_length_out_of_bounds_destination",
        "single_byte_rewrite",
        "full_word_rewrite",
        "single_byte_forward_overwrite",
        "full_word_forward_overwrite",
        "mid_word_single_byte_rewrite",
        "mid_word_single_word_rewrite",
        "mid_word_multi_word_rewrite",
        "two_words_forward_overwrite",
        "two_words_backward_overwrite",
        "two_words_backward_overwrite_single_byte_offset",
        "single_byte_memory_extension",
        "single_word_memory_extension",
        "single_word_minus_one_byte_memory_extension",
        "single_word_plus_one_byte_memory_extension",
        "full_memory_rewrite",
        "full_memory_copy",
        "full_memory_copy_offset",
        "full_memory_clean",
        "out_of_bounds_memory_extension",
    ],
)
@pytest.mark.valid_from("Cancun")
def test_valid_mcopy_operations(
    state_test: StateTestFiller,
    pre: Alloc,
    post: Mapping[str, Account],
    tx: Transaction,
) -> None:
    """
    Perform MCOPY operations using different offsets and lengths.

      - Zero inputs
      - Memory rewrites (copy from and to the same location)
      - Memory overwrites (copy from and to different locations)
      - Memory extensions (copy to a location that is out of bounds)
      - Memory clear (copy from a location that is out of bounds).
    """
    state_test(pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 21 parametrized test cases across 5 forks.