Skip to content

test_invalid_tx_invalid_authorization_tuple_missing_element()

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

Test sending a transaction where the authorization tuple field of the type-4 transaction is serialized to miss one element.

Source code in tests/prague/eip7702_set_code_tx/test_invalid_tx.py
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
@pytest.mark.parametrize(
    "missing_index",
    [
        pytest.param(0, id="missing_chain_id"),
        pytest.param(1, id="missing_address"),
        pytest.param(2, id="missing_nonce"),
        pytest.param(3, id="missing_signature_y_parity"),
        pytest.param(4, id="missing_signature_r"),
        pytest.param(5, id="missing_signature_s"),
    ],
)
@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_missing_element(
    transaction_test: TransactionTestFiller,
    pre: Alloc,
    delegate_address: Address,
    missing_index: int,
) -> None:
    """
    Test sending a transaction where the authorization tuple field of the
    type-4 transaction is serialized to miss one element.
    """
    auth_signer = pre.fund_eoa()

    class MissingElementAuthorizationTuple(AuthorizationTuple):
        missing_element_index: int

        def get_rlp_fields(self) -> List[str]:
            """
            Remove the field that is specified by the missing element index.
            """
            rlp_fields = super().get_rlp_fields()[:]
            rlp_fields.pop(self.missing_element_index)
            return rlp_fields

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

    transaction_test(
        pre=pre,
        tx=tx,
    )

Parametrized Test Cases

This test generates 12 parametrized test cases across 3 forks.