Skip to content

test_insert_into_committed_extension()

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

Generate fixtures for these test cases for Bogota with:

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

Insert a key that diverges in the middle of a committed extension.

pre: ext(5) -> branch@5 -> {l1, l2} post: ext(2) -> branch@2 -> {l3, ext(2) -> branch@5 -> {l1, l2}}

Source code in tests/mpt/test_storage_trie_structure.py
def test_insert_into_committed_extension(
    state_test: StateTestFiller, pre: Alloc
) -> None:
    """
    Insert a key that diverges in the middle of a committed extension.

    pre:  ext(5) -> branch@5 -> {l1, l2}
    post: ext(2) -> branch@2 -> {l3, ext(2) -> branch@5 -> {l1, l2}}
    """
    l1, l2, l3 = EXT_MERGE_TRIO
    assert storage_shape([l1, l2], l1) == [
        (0, "ext", 5),
        (5, "branch", 2),
        (6, "leaf", 58),
    ]
    assert storage_shape([l1, l2, l3], l1) == [
        (0, "ext", 2),
        (2, "branch", 2),
        (3, "ext", 2),
        (5, "branch", 2),
        (6, "leaf", 58),
    ]
    contract = pre.deploy_contract(
        code=_writer_code([(l3, 3)]), storage={l1: 1, l2: 2}
    )

    state_test(
        pre=pre,
        tx=Transaction(sender=pre.fund_eoa(), to=contract),
        post={contract: Account(storage={l1: 1, l2: 2, l3: 3})},
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 3 forks.