Skip to content

test_valid_mcopy_operations()

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

Generate fixtures for these test cases for Osaka with:

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

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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
@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(
        env=Environment(),
        pre=pre,
        post=post,
        tx=tx,
    )

Parametrized Test Cases

This test generates 21 parametrized test cases across 3 forks.