Skip to content

test_invalid_log_length()

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

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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
@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.