Skip to content

test_zero_gas_price_nonexistent_sender()

Documentation for tests/frontier/touch/test_touch.py::test_zero_gas_price_nonexistent_sender@b314d18e.

Generate fixtures for these test cases for Berlin with:

fill -v tests/frontier/touch/test_touch.py::test_zero_gas_price_nonexistent_sender --fork Berlin

Test a zero gasprice, zero value transaction from a sender that does not exist in the pre-state.

Because the transaction is free (gas_price=0) and transfers no value, no balance is ever deducted from the sender, so the sender account is only materialized when its nonce is incremented. Clients must create the sender account in this case rather than failing on a missing account.

Source code in tests/frontier/touch/test_touch.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
@pytest.mark.valid_from("Frontier")
@pytest.mark.valid_before("EIP1559")
def test_zero_gas_price_nonexistent_sender(
    state_test: StateTestFiller,
    pre: Alloc,
) -> None:
    """
    Test a zero gasprice, zero value transaction from a sender that does not
    exist in the pre-state.

    Because the transaction is free (gas_price=0) and transfers no value, no
    balance is ever deducted from the sender, so the sender account is only
    materialized when its nonce is incremented. Clients must create the sender
    account in this case rather than failing on a missing account.

    """
    # amount=0 means the sender is NOT added to the pre-alloc.
    sender = pre.fund_eoa(amount=0)

    contract = pre.deploy_contract(
        code=(Op.SSTORE(0, 0x01) + Op.STOP),
    )

    tx = Transaction(
        to=contract,
        gas_price=0,  # Part of the test, do not change.
        value=0,  # Part of the test, do not change.
        sender=sender,
        protected=False,
    )

    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post={
            contract: Account(storage={0: 0x01}),
            sender: Account(nonce=1, balance=0),
        },
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 9 forks.