Skip to content

test_set_code_multiple_valid_authorization_tuples_same_signer_increasing_nonce_self_sponsored()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_multiple_valid_authorization_tuples_same_signer_increasing_nonce_self_sponsored@2867859a.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_multiple_valid_authorization_tuples_same_signer_increasing_nonce_self_sponsored --fork Amsterdam

Test setting the code of an account with multiple authorization tuples from the same signer and each authorization tuple has an increasing nonce, therefore the last tuple is executed, and the transaction is self-sponsored.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs.py
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
@pytest.mark.bigmem
@pytest.mark.xdist_group(name="bigmem")
def test_set_code_multiple_valid_authorization_tuples_same_signer_increasing_nonce_self_sponsored(  # noqa: E501
    state_test: StateTestFiller,
    pre: Alloc,
) -> None:
    """
    Test setting the code of an account with multiple authorization tuples from
    the same signer and each authorization tuple has an increasing nonce,
    therefore the last tuple is executed, and the transaction is
    self-sponsored.
    """
    auth_signer = pre.fund_eoa()

    tuple_count = 10

    success_slot = tuple_count - 1

    addresses = [
        pre.deploy_contract(Op.SSTORE(i, 1) + Op.STOP)
        for i in range(tuple_count)
    ]

    tx = Transaction(
        to=auth_signer,
        value=0,
        authorization_list=[
            AuthorizationTuple(
                address=address,
                nonce=i + 1,
                signer=auth_signer,
            )
            for i, address in enumerate(addresses)
        ],
        sender=auth_signer,
    )

    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post={
            auth_signer: Account(
                nonce=11,
                code=Spec.delegation_designation(addresses[success_slot]),
                storage={
                    success_slot: 1,
                },
            ),
        },
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 3 forks.