Skip to content

test_mixed_zero_nonzero_bytes_floor_cost()

Documentation for tests/amsterdam/eip7981_increase_access_list_cost/test_transaction_validity.py::test_mixed_zero_nonzero_bytes_floor_cost@c74f1a67.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7981_increase_access_list_cost/test_transaction_validity.py::test_mixed_zero_nonzero_bytes_floor_cost --fork Amsterdam

Test floor cost calculation with mixed zero and non-zero bytes.

This ensures floor gas uses floor token counting: - Each data byte contributes 4 floor tokens

Source code in tests/amsterdam/eip7981_increase_access_list_cost/test_transaction_validity.py
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@pytest.mark.with_all_tx_types(selector=lambda tx_type: tx_type >= 1)
@pytest.mark.parametrize(
    "access_list,tx_data",
    [
        pytest.param(
            [AccessList(address=Address(0), storage_keys=[Hash(0)] * 100)],
            Bytes(b"\x00" * 1000),
            id="zero_heavy_data_and_access_list",
        ),
        pytest.param(
            [
                AccessList(
                    address=Address(
                        0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
                    ),
                    storage_keys=[
                        Hash(
                            0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
                        )
                    ]
                    * 50,
                )
            ],
            Bytes(b"\xff" * 500),
            id="nonzero_heavy_data_and_access_list",
        ),
    ],
)
@pytest.mark.parametrize(
    "to",
    [pytest.param("eoa", id="")],
    indirect=True,
)
@pytest.mark.parametrize(
    "tx_gas_delta",
    [pytest.param(0, id="")],
)
def test_mixed_zero_nonzero_bytes_floor_cost(
    state_test: StateTestFiller,
    pre: Alloc,
    tx: Transaction,
) -> None:
    """
    Test floor cost calculation with mixed zero and non-zero bytes.

    This ensures floor gas uses floor token counting:
    - Each data byte contributes 4 floor tokens
    """
    state_test(
        pre=pre,
        post={},
        tx=tx,
    )

Parametrized Test Cases

This test generates 8 parametrized test cases across 1 fork.