Skip to content

test_invalid_tx_invalid_authorization_tuple_extra_element()

Documentation for tests/prague/eip7702_set_code_tx/test_invalid_tx.py::test_invalid_tx_invalid_authorization_tuple_extra_element@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_authorization_tuple_extra_element --fork Amsterdam

Test sending a transaction where the authorization tuple field of the type-4 transaction is serialized to contain an extra element.

Source code in tests/prague/eip7702_set_code_tx/test_invalid_tx.py
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
@pytest.mark.parametrize("extra_element_value", [0, 1])
@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_authorization_tuple_extra_element(
    transaction_test: TransactionTestFiller,
    pre: Alloc,
    delegate_address: Address,
    extra_element_value: int,
) -> None:
    """
    Test sending a transaction where the authorization tuple field of the
    type-4 transaction is serialized to contain an extra element.
    """
    auth_signer = pre.fund_eoa()

    class ExtraElementAuthorizationTuple(AuthorizationTuple):
        extra_element: HexNumber

        def get_rlp_fields(self) -> List[str]:
            """
            Append the extra field to the list of fields to be encoded in RLP.
            """
            rlp_fields = super().get_rlp_fields()[:]
            rlp_fields.append("extra_element")
            return rlp_fields

    tx = Transaction(
        gas_limit=100_000,
        to=0,
        value=0,
        authorization_list=[
            ExtraElementAuthorizationTuple(
                address=delegate_address,
                nonce=0,
                signer=auth_signer,
                extra_element=extra_element_value,
            ),
        ],
        error=TransactionException.TYPE_4_INVALID_AUTHORIZATION_FORMAT,
        sender=pre.fund_eoa(),
    )

    transaction_test(
        pre=pre,
        tx=tx,
    )

Parametrized Test Cases

This test generates 4 parametrized test cases across 3 forks.