test_sender_balance_insufficient_state_test()
Documentation for tests/frontier/validation/test_transaction.py::test_sender_balance_insufficient_state_test@b314d18e.
Generate fixtures for these test cases for Amsterdam with:
fill -v tests/frontier/validation/test_transaction.py::test_sender_balance_insufficient_state_test --fork Amsterdam
A legacy transaction from a sender that cannot afford gas * gasPrice
must be rejected, exercised through the state-test code path.
Source code in tests/frontier/validation/test_transaction.py
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198 | @pytest.mark.valid_from("Frontier")
@pytest.mark.state_test_only
@pytest.mark.exception_test
@pytest.mark.eels_base_coverage
def test_sender_balance_insufficient_state_test(
state_test: StateTestFiller,
pre: Alloc,
) -> None:
"""
A legacy transaction from a sender that cannot afford `gas * gasPrice`
must be rejected, exercised through the state-test code path.
"""
storage = Storage()
# If the transaction were (incorrectly) executed, this SSTORE would land a
# non-default value in slot 0, diverging the post-state root from the
# rejected (pre == post) outcome.
contract = pre.deploy_contract(
code=Op.SSTORE(storage.store_next(0, "must_stay_unset"), 0x1)
+ Op.STOP,
)
# Zero balance, unable to cover any gas cost.
sender = pre.fund_eoa(amount=0)
tx = Transaction(
sender=sender,
to=contract,
gas_limit=100_000,
gas_price=10,
protected=False, # legacy tx
error=TransactionException.INSUFFICIENT_ACCOUNT_FUNDS,
)
state_test(
env=Environment(),
pre=pre,
# Transaction rejected: contract storage stays empty.
post={contract: Account(storage=storage)},
tx=tx,
)
|
Parametrized Test Cases
This test generates 1 parametrized test case across 16 forks.