Skip to content

test_delete_missing_is_noop()

Documentation for tests/mpt/test_storage_trie_structure.py::test_delete_missing_is_noop@ffe48572.

Generate fixtures for these test cases for Bogota with:

fill -v tests/mpt/test_storage_trie_structure.py::test_delete_missing_is_noop --fork Bogota

Zero a slot that is not in the trie; the root does not change.

leaf(64), ext(5) -> branch@5 -> {..}, or

ext(4) -> branch@4 -> {15 x leaf(59)}

post: identical The slot's path ends at another leaf, inside an extension or at an empty branch slot.

Source code in tests/mpt/test_storage_trie_structure.py
@pytest.mark.parametrize(
    "committed,absent,pre_shape",
    [
        pytest.param(
            [SINGLE_SLOT],
            ROOT_PAIR[1],
            [(0, "leaf", 64)],
            id="leaf_mismatch",
        ),
        pytest.param(
            EXT_MERGE_TRIO[:2],
            EXT_MERGE_TRIO[2],
            [(0, "ext", 5), (5, "branch", 2), (6, "leaf", 58)],
            id="ext_mismatch",
        ),
        pytest.param(
            SIXTEEN_SLOTS_BRANCH4[:15],
            SIXTEEN_SLOTS_BRANCH4[15],
            [(0, "ext", 4), (4, "branch", 15), (5, "leaf", 59)],
            id="empty_slot",
        ),
    ],
)
def test_delete_missing_is_noop(
    state_test: StateTestFiller,
    pre: Alloc,
    committed: Sequence[int],
    absent: int,
    pre_shape: Shape,
) -> None:
    """
    Zero a slot that is not in the trie; the root does not change.

    pre:  leaf(64), ext(5) -> branch@5 -> {..}, or
          ext(4) -> branch@4 -> {15 x leaf(59)}
    post: identical
    The slot's path ends at another leaf, inside an extension or at an
    empty branch slot.
    """
    storage = _storage(committed)
    assert storage_shape(committed, committed[0]) == pre_shape
    assert absent not in storage
    contract = pre.deploy_contract(
        code=_writer_code([(absent, 0)]), storage=storage
    )

    state_test(
        pre=pre,
        tx=Transaction(sender=pre.fund_eoa(), to=contract),
        post={contract: Account(storage=storage)},
    )

Parametrized Test Cases

This test generates 3 parametrized test cases across 3 forks.