Skip to content

test_delete_resurrect_delete_across_blocks()

Documentation for tests/mpt/test_account_trie_structure.py::test_delete_resurrect_delete_across_blocks@02aafd78.

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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
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.