Skip to content

test_delete_resurrect_delete_across_blocks()

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

Generate fixtures for these test cases for Bogota with:

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

Delete a leaf, re-create it by a transfer, delete it again.

pre: .. -> branch@4 -> {survivor, doomed} post: block 1: leaf survivor; block 2: the pre shape; block 3: leaf The resurrected balance-only account is deployable again, so the same CREATE2 deletes it a second time from persisted nodes.

Source code in tests/mpt/test_account_trie_structure.py
def test_delete_resurrect_delete_across_blocks(
    blockchain_test: BlockchainTestFiller, pre: Alloc
) -> None:
    """
    Delete a leaf, re-create it by a transfer, delete it again.

    pre:  .. -> branch@4 -> {survivor, doomed}
    post: block 1: leaf survivor; block 2: the pre shape; block 3: leaf
    The resurrected balance-only account is deployable again, so the
    same CREATE2 deletes it a second time from persisted nodes.
    """
    survivor, doomed, sender = _fund_collapse_pair(pre)
    after = account_shape(_after_block(pre, doomed), survivor)
    assert covering(after, 4)[1] == "leaf"

    blockchain_test(
        pre=pre,
        post={survivor: Account(balance=1), doomed: Account.NONEXISTENT},
        blocks=[
            Block(
                txs=[_delete_tx(sender, COLLAPSE_SALT)],
                expected_post_state={doomed: Account.NONEXISTENT},
            ),
            Block(
                txs=[Transaction(sender=sender, to=doomed, value=1)],
                expected_post_state={doomed: Account(balance=1)},
            ),
            Block(txs=[_delete_tx(sender, COLLAPSE_SALT)]),
        ],
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 3 forks.