Skip to content

test_invalid_log_length()

Documentation for tests/prague/eip6110_deposits/test_modified_contract.py::test_invalid_log_length@ffe48572.

Generate fixtures for these test cases for Bogota with:

fill -v tests/prague/eip6110_deposits/test_modified_contract.py::test_invalid_log_length --fork Bogota

Test deposit contract emitting logs with invalid log length (one byte more or less).

Source code in tests/prague/eip6110_deposits/test_modified_contract.py
@pytest.mark.parametrize("slice_bytes", [True, False])
@pytest.mark.exception_test
@pytest.mark.eels_base_coverage
def test_invalid_log_length(
    blockchain_test: BlockchainTestFiller, pre: Alloc, slice_bytes: bool
) -> None:
    """
    Test deposit contract emitting logs with invalid log length (one byte more
    or less).
    """
    changed_log = (
        DEFAULT_REQUEST_LOG[:-1]
        if slice_bytes
        else DEFAULT_REQUEST_LOG + b"\x00"
    )

    bytecode = Om.MSTORE(changed_log) + Op.LOG1(
        0,
        len(changed_log),
        Spec.DEPOSIT_EVENT_SIGNATURE_HASH,
    )
    bytecode += Op.STOP

    pre.update_account(DepositRequest.system_contract_address, code=bytecode)
    sender = pre.fund_eoa()

    tx = Transaction(
        to=DepositRequest.system_contract_address,
        sender=sender,
        gas_limit=100_000,
    )

    blockchain_test(
        pre=pre,
        blocks=[
            Block(
                txs=[tx],
                exception=[
                    BlockException.INVALID_DEPOSIT_EVENT_LAYOUT,
                ],
            ),
        ],
        post={},
    )

Parametrized Test Cases

This test generates 2 parametrized test cases across 4 forks.