Skip to content

test_invalid_chain_id()

Documentation for tests/london/eip1559_fee_market_change/test_tx_type.py::test_invalid_chain_id@2867859a.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/london/eip1559_fee_market_change/test_tx_type.py::test_invalid_chain_id --fork Amsterdam

Test that a transaction with a different chain id is not valid.

Source code in tests/london/eip1559_fee_market_change/test_tx_type.py
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
@pytest.mark.valid_from("SpuriousDragon")
@pytest.mark.exception_test
@pytest.mark.with_all_tx_types
def test_invalid_chain_id(
    state_test: StateTestFiller,
    pre: Alloc,
    chain_config: ChainConfig,
    tx_type: int,
) -> None:
    """
    Test that a transaction with a different chain id is not valid.
    """
    to = pre.fund_eoa(0xDEADBEEE)

    blob_versioned_hashes = add_kzg_version([0], 1) if tx_type == 3 else None
    tx = Transaction(
        sender=pre.fund_eoa(),
        value=1,
        chain_id=chain_config.chain_id + 1,
        ty=tx_type,
        to=to,
        error=TransactionException.INVALID_CHAINID,
        blob_versioned_hashes=blob_versioned_hashes,
    )

    state_test(
        pre=pre,
        tx=tx,
        post={
            to: Account(balance=0xDEADBEEE),
        },
    )

Parametrized Test Cases

This test generates 5 parametrized test cases across 13 forks.