Skip to content

test_delete_missing_is_noop()

Documentation for tests/mpt/test_storage_trie_structure.py::test_delete_missing_is_noop@02aafd78.

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
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
@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.