Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions tests/frontier/touch/test_touch.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,45 @@ def test_zero_gas_price_and_touching(
tx=tx,
post={contract: Account(storage={0: value})},
)


@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),
},
)
Loading