Skip to content

test_invalid_tx_invalid_auth_chain_id_encoding()

Documentation for tests/prague/eip7702_set_code_tx/test_invalid_tx.py::test_invalid_tx_invalid_auth_chain_id_encoding@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/prague/eip7702_set_code_tx/test_invalid_tx.py::test_invalid_tx_invalid_auth_chain_id_encoding --fork Amsterdam

Test sending a transaction where the chain id field of an authorization has an incorrect encoding.

Source code in tests/prague/eip7702_set_code_tx/test_invalid_tx.py
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
@pytest.mark.parametrize(
    "auth_chain_id, oversized_type",
    [
        pytest.param(0, OversizedZeroInt, id="zero_oversized_zero"),
        pytest.param(0, OversizedInt, id="zero_oversized_int"),
        pytest.param(1, OversizedInt, id="one_oversized_int"),
    ],
)
@pytest.mark.parametrize(
    "delegate_address",
    [
        pytest.param(
            Spec.RESET_DELEGATION_ADDRESS, id="reset_delegation_address"
        ),
        pytest.param(Address(1), id="non_zero_address"),
    ],
)
def test_invalid_tx_invalid_auth_chain_id_encoding(
    transaction_test: TransactionTestFiller,
    pre: Alloc,
    delegate_address: Address,
    auth_chain_id: int,
    oversized_type: type,
) -> None:
    """
    Test sending a transaction where the chain id field of an authorization has
    an incorrect encoding.
    """

    class ModifiedAuthorizationTuple(AuthorizationTuple):
        chain_id: oversized_type  # type: ignore

    authorization = ModifiedAuthorizationTuple(
        address=delegate_address,
        nonce=0,
        chain_id=auth_chain_id,
        signer=pre.fund_eoa(auth_account_start_balance),
    )

    tx = Transaction(
        gas_limit=100_000,
        to=0,
        value=0,
        authorization_list=[authorization],
        error=TransactionException.TYPE_4_INVALID_AUTHORIZATION_FORMAT,
        sender=pre.fund_eoa(),
    )

    transaction_test(
        pre=pre,
        tx=tx,
    )

Parametrized Test Cases

This test generates 6 parametrized test cases across 3 forks.