Skip to content

test_bal_selfdestruct_to_system_address_zero_balance()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_opcodes.py::test_bal_selfdestruct_to_system_address_zero_balance@a9abd46e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_opcodes.py::test_bal_selfdestruct_to_system_address_zero_balance --fork Amsterdam

Ensure SYSTEM_ADDRESS is in BAL when accessed via SELFDESTRUCT, even with zero balance transferred. Companion to test_bal_account_touch_system_address, which covers the BALANCE/EXTCODE*/CALL/STATICCALL opcodes.

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_opcodes.py
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
def test_bal_selfdestruct_to_system_address_zero_balance(
    pre: Alloc,
    blockchain_test: BlockchainTestFiller,
) -> None:
    """
    Ensure `SYSTEM_ADDRESS` is in BAL when accessed via `SELFDESTRUCT`,
    even with zero balance transferred. Companion to
    `test_bal_account_touch_system_address`, which covers the
    `BALANCE`/`EXTCODE*`/`CALL`/`STATICCALL` opcodes.
    """
    alice = pre.fund_eoa()

    init_code = Op.SELFDESTRUCT(SYSTEM_ADDRESS)
    new_contract = compute_create_address(address=alice, nonce=0)

    tx = Transaction(
        sender=alice,
        to=None,  # CREATE
        value=0,  # zero contract balance at SELFDESTRUCT time
        data=init_code,
    )

    block = Block(
        txs=[tx],
        expected_block_access_list=BlockAccessListExpectation(
            account_expectations={
                alice: BalAccountExpectation(
                    nonce_changes=[
                        BalNonceChange(block_access_index=1, post_nonce=1),
                    ],
                ),
                SYSTEM_ADDRESS: BalAccountExpectation.empty(),
            }
        ),
    )

    blockchain_test(
        pre=pre,
        blocks=[block],
        post={
            alice: Account(nonce=1),
            new_contract: Account.NONEXISTENT,
        },
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.