test_tx_nonce()
Documentation for tests/frontier/validation/test_transaction.py::test_tx_nonce@c17999c0.
Generate fixtures for these test cases for Amsterdam with:
fill -v tests/frontier/validation/test_transaction.py::test_tx_nonce --fork Amsterdam
Tests that the tx nonce matches the account nonce.
Source code in tests/frontier/validation/test_transaction.py
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102 | @pytest.mark.parametrize(
"nonce_diff, expected_exception",
[
pytest.param(
-1,
TransactionException.NONCE_MISMATCH_TOO_LOW,
marks=pytest.mark.exception_test,
),
(0, None), # Valid case - no exception
pytest.param(
1,
TransactionException.NONCE_MISMATCH_TOO_HIGH,
marks=pytest.mark.exception_test,
),
],
)
@pytest.mark.pre_alloc_mutable
@pytest.mark.eels_base_coverage
def test_tx_nonce(
state_test: StateTestFiller,
pre: Alloc,
nonce_diff: int,
expected_exception: TransactionException | None,
) -> None:
"""
Tests that the tx nonce matches the account nonce.
"""
sender = pre.fund_eoa(nonce=5)
to = pre.fund_eoa()
tx = Transaction(
to=to,
nonce=sender.nonce + nonce_diff,
sender=sender,
protected=False,
error=expected_exception,
)
state_test(pre=pre, post={}, tx=tx)
|
Parametrized Test Cases
This test generates 3 parametrized test cases across 16 forks.