Skip to content

test_tx_at_nonce_max_minus_one_create()

Documentation for tests/frontier/eip2681_limit_account_nonce/test_nonce_reaching_max.py::test_tx_at_nonce_max_minus_one_create@8acae1b0.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/frontier/eip2681_limit_account_nonce/test_nonce_reaching_max.py::test_tx_at_nonce_max_minus_one_create --fork Amsterdam

Test that a top-level CREATE transaction from a sender at the highest usable nonce (2**64 - 2) executes normally, creating a contract and bumping the sender to the maximum nonce (2**64 - 1).

Source code in tests/frontier/eip2681_limit_account_nonce/test_nonce_reaching_max.py
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
87
@pytest.mark.valid_from("Frontier")
@pytest.mark.pre_alloc_mutable
def test_tx_at_nonce_max_minus_one_create(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Test that a top-level CREATE transaction from a sender at the highest
    usable nonce (`2**64 - 2`) executes normally, creating a contract and
    bumping the sender to the maximum nonce (`2**64 - 1`).
    """
    sender = pre.fund_eoa(nonce=Spec.max_nonce - 1)

    tx = Transaction(
        to=None,
        nonce=Spec.max_nonce - 1,
        sender=sender,
        protected=False,
    )

    # EIP-161 (Spurious Dragon) initializes a new contract's nonce to 1.
    created_nonce = 1 if fork >= SpuriousDragon else 0
    created = compute_create_address(address=sender, nonce=Spec.max_nonce - 1)

    state_test(
        pre=pre,
        post={
            sender: Account(nonce=Spec.max_nonce),
            created: Account(nonce=created_nonce, code=b""),
        },
        tx=tx,
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 16 forks.