Skip to content

test_insert_into_committed_extension()

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

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
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
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.