Skip to content

test_invalid_log_length()

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

Generate fixtures for these test cases for Prague with:

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

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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
@pytest.mark.parametrize(
    "slice_bytes",
    [
        pytest.param(True),
        pytest.param(False),
    ],
)
@pytest.mark.exception_test
def test_invalid_log_length(blockchain_test: BlockchainTestFiller, pre: Alloc, slice_bytes: bool):
    """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[Spec.DEPOSIT_CONTRACT_ADDRESS] = Account(
        code=bytecode,
        nonce=1,
        balance=0,
    )
    sender = pre.fund_eoa()

    tx = Transaction(
        to=Spec.DEPOSIT_CONTRACT_ADDRESS,
        sender=sender,
        gas_limit=100_000,
        error=TransactionException.INVALID_DEPOSIT_EVENT_LAYOUT,
    )

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

Parametrized Test Cases

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

Test ID (Abbreviated) slice_bytes
...fork_Prague-blockchain_test-slice_bytes_True True
...fork_Prague-blockchain_test-slice_bytes_False False
...fork_Osaka-blockchain_test-slice_bytes_True True
...fork_Osaka-blockchain_test-slice_bytes_False False