Skip to content

test_bal_7702_null_address_delegation_no_code_change()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip7702.py::test_bal_7702_null_address_delegation_no_code_change@c74f1a67.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip7702.py::test_bal_7702_null_address_delegation_no_code_change --fork Amsterdam

Ensure BAL does not record spurious code changes when delegating to NULL_ADDRESS (sets code to empty on an account that already has empty code).

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip7702.py
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
def test_bal_7702_null_address_delegation_no_code_change(
    pre: Alloc,
    blockchain_test: BlockchainTestFiller,
) -> None:
    """
    Ensure BAL does not record spurious code changes when delegating to
    NULL_ADDRESS (sets code to empty on an account that already has
    empty code).
    """
    alice = pre.fund_eoa()
    bob = pre.fund_eoa(amount=0)

    tx = Transaction(
        sender=alice,
        to=bob,
        value=10,
        authorization_list=[
            AuthorizationTuple(
                address=0,
                nonce=1,
                signer=alice,
            )
        ],
    )

    # `alice` should appear in BAL with nonce change only, NOT code change
    # because setting code from b"" to b"" is a net-zero change
    account_expectations = {
        alice: BalAccountExpectation(
            nonce_changes=[BalNonceChange(block_access_index=1, post_nonce=2)],
            code_changes=[],  # explicit check for no code changes
        ),
        bob: BalAccountExpectation(
            balance_changes=[
                BalBalanceChange(block_access_index=1, post_balance=10)
            ]
        ),
    }

    blockchain_test(
        pre=pre,
        blocks=[
            Block(
                txs=[tx],
                expected_block_access_list=BlockAccessListExpectation(
                    account_expectations=account_expectations
                ),
            )
        ],
        post={
            alice: Account(nonce=2, code=b""),
            bob: Account(balance=10),
        },
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.