Skip to content

test_bal_nonexistent_value_transfer()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py::test_bal_nonexistent_value_transfer@5c024cbb.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py::test_bal_nonexistent_value_transfer --fork Amsterdam

Ensure BAL captures non-existent account on value transfer.

Alice sends value directly to non-existent Bob.

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
@pytest.mark.parametrize(
    "value",
    [
        pytest.param(0, id="zero_value"),
        pytest.param(1, id="positive_value"),
    ],
)
def test_bal_nonexistent_value_transfer(
    pre: Alloc,
    blockchain_test: BlockchainTestFiller,
    value: int,
) -> None:
    """
    Ensure BAL captures non-existent account on value transfer.

    Alice sends value directly to non-existent Bob.
    """
    alice = pre.fund_eoa()
    bob = pre.nonexistent_account()

    tx = Transaction(sender=alice, to=bob, value=value)

    block = Block(
        txs=[tx],
        expected_block_access_list=BlockAccessListExpectation(
            account_expectations={
                alice: BalAccountExpectation(
                    nonce_changes=[
                        BalNonceChange(block_access_index=1, post_nonce=1)
                    ],
                ),
                bob: BalAccountExpectation(
                    balance_changes=[
                        BalBalanceChange(
                            block_access_index=1, post_balance=value
                        )
                    ]
                    if value > 0
                    else [],
                ),
            }
        ),
    )

    blockchain_test(
        pre=pre,
        blocks=[block],
        post={
            alice: Account(nonce=1),
            bob: Account(balance=value) if value > 0 else Account.NONEXISTENT,
        },
    )

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.