Skip to content

test_invalid_tx_invalid_rlp_encoding()

Documentation for tests/prague/eip7702_set_code_tx/test_invalid_tx.py::test_invalid_tx_invalid_rlp_encoding@44293f1e.

Generate fixtures for these test cases for Prague with:

fill -v tests/prague/eip7702_set_code_tx/test_invalid_tx.py::test_invalid_tx_invalid_rlp_encoding --fork Prague

Test sending a transaction type-4 where the RLP encoding of the transaction is invalid.

Source code in tests/prague/eip7702_set_code_tx/test_invalid_tx.py
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
@pytest.mark.parametrize(
    "invalid_rlp_mode",
    [
        pytest.param(InvalidRLPMode.TRUNCATED_RLP, id="truncated_rlp"),
        pytest.param(InvalidRLPMode.EXTRA_BYTES, id="extra_bytes"),
    ],
)
@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_rlp_encoding(
    transaction_test: TransactionTestFiller,
    pre: Alloc,
    delegate_address: Address,
    invalid_rlp_mode: InvalidRLPMode,
):
    """
    Test sending a transaction type-4 where the RLP encoding of the transaction is
    invalid.
    """
    auth_signer = pre.fund_eoa()

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

    if invalid_rlp_mode == InvalidRLPMode.TRUNCATED_RLP:
        # Truncate the last byte of the RLP encoding
        tx.rlp_override = Bytes(tx.rlp()[:-1])
    elif invalid_rlp_mode == InvalidRLPMode.EXTRA_BYTES:
        # Add an extra byte to the end of the RLP encoding
        tx.rlp_override = Bytes(tx.rlp() + b"\x00")

    transaction_test(
        pre=pre,
        tx=tx,
    )

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) delegate_address invalid_rlp_mode
...fork_Prague-transaction_test-reset_delegation_address-truncated_rlp 0x000000000000000000000000000000 0000000000 InvalidRLPMode.TRUNCATED_RLP
...fork_Prague-transaction_test-reset_delegation_address-extra_bytes 0x000000000000000000000000000000 0000000000 InvalidRLPMode.EXTRA_BYTES
...fork_Prague-transaction_test-non_zero_address-truncated_rlp 0x000000000000000000000000000000 0000000001 InvalidRLPMode.TRUNCATED_RLP
...fork_Prague-transaction_test-non_zero_address-extra_bytes 0x000000000000000000000000000000 0000000001 InvalidRLPMode.EXTRA_BYTES
...fork_Osaka-transaction_test-reset_delegation_address-truncated_rlp 0x000000000000000000000000000000 0000000000 InvalidRLPMode.TRUNCATED_RLP
...fork_Osaka-transaction_test-reset_delegation_address-extra_bytes 0x000000000000000000000000000000 0000000000 InvalidRLPMode.EXTRA_BYTES
...fork_Osaka-transaction_test-non_zero_address-truncated_rlp 0x000000000000000000000000000000 0000000001 InvalidRLPMode.TRUNCATED_RLP
...fork_Osaka-transaction_test-non_zero_address-extra_bytes 0x000000000000000000000000000000 0000000001 InvalidRLPMode.EXTRA_BYTES