Skip to content

test_tx_max_nonce()

Documentation for tests/frontier/validation/test_transaction.py::test_tx_max_nonce@5fa5938b.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/frontier/validation/test_transaction.py::test_tx_max_nonce --fork Amsterdam

Test that a transaction with the maximum nonce value (2**64 - 1) is rejected, as the maximum usable nonce is 2**64 - 2.

The sender account is funded at the same nonce so that clients which check nonce equality first reach the max-nonce check instead of rejecting the transaction with a nonce mismatch.

Source code in tests/frontier/validation/test_transaction.py
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
@pytest.mark.pre_alloc_mutable
@pytest.mark.exception_test
@pytest.mark.eels_base_coverage
def test_tx_max_nonce(state_test: StateTestFiller, pre: Alloc) -> None:
    """
    Test that a transaction with the maximum nonce value (`2**64 - 1`) is
    rejected, as the maximum usable nonce is `2**64 - 2`.

    The sender account is funded at the same nonce so that clients which
    check nonce equality first reach the max-nonce check instead of
    rejecting the transaction with a nonce mismatch.
    """
    max_nonce = 2**64 - 1
    sender = pre.fund_eoa(nonce=max_nonce)
    to = pre.nonexistent_account()

    tx = Transaction(
        to=to,
        nonce=max_nonce,
        sender=sender,
        protected=False,
        error=TransactionException.NONCE_IS_MAX,
    )

    state_test(pre=pre, post={sender: Account(nonce=max_nonce)}, tx=tx)

Parametrized Test Cases

This test generates 1 parametrized test case across 16 forks.