Skip to content

test_mass_delete_sixteen_to_one()

Documentation for tests/mpt/test_account_trie_structure.py::test_mass_delete_sixteen_to_one@ffe48572.

Generate fixtures for these test cases for Bogota with:

fill -v tests/mpt/test_account_trie_structure.py::test_mass_delete_sixteen_to_one --fork Bogota

Delete fifteen of sixteen accounts under one branch in one block.

pre: .. -> ext -> branch@4 -> {survivor, 15 x doomed} post: .. -> leaf survivor The branch collapses onto the survivor, which merges with the extension above.

Source code in tests/mpt/test_account_trie_structure.py
def test_mass_delete_sixteen_to_one(
    blockchain_test: BlockchainTestFiller, pre: Alloc
) -> None:
    """
    Delete fifteen of sixteen accounts under one branch in one block.

    pre:  .. -> ext -> branch@4 -> {survivor, 15 x doomed}
    post: .. -> leaf survivor
    The branch collapses onto the survivor, which merges with the
    extension above.
    """
    survivor = Address(SIXTEEN_ADDRS_BRANCH4[0])
    doomed = [_create2_address(s) for s in SIXTEEN_SALTS_BRANCH4]
    pre.fund_address(survivor, amount=1)
    for address in doomed:
        pre.fund_address(address, amount=FUNDING)
    _ensure_factory(pre)
    sender = pre.fund_eoa()
    before = account_shape(pre, survivor)
    assert node_at(before, 4) == ("branch", 16)
    assert before[before.index((4, "branch", 16)) - 1][1] == "ext"
    after = account_shape(_after_block(pre, *doomed), survivor)
    assert covering(after, 4)[1] == "leaf"

    blockchain_test(
        pre=pre,
        post={
            survivor: Account(balance=1),
            **dict.fromkeys(doomed, Account.NONEXISTENT),
        },
        blocks=[
            Block(txs=[_delete_tx(sender, s) for s in SIXTEEN_SALTS_BRANCH4])
        ],
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 3 forks.