Skip to content

test_call_identity_precompile_large_params()

Documentation for tests/frontier/identity_precompile/test_identity.py::test_call_identity_precompile_large_params@ffe48572.

Generate fixtures for these test cases for Bogota with:

fill -v tests/frontier/identity_precompile/test_identity.py::test_call_identity_precompile_large_params --fork Bogota

Test identity precompile when out of gas occurs.

Source code in tests/frontier/identity_precompile/test_identity.py
@pytest.mark.ported_from(
    [
        "https://github.com/ethereum/tests/blob/v17.1/src/GeneralStateTestsFiller/stPreCompiledContracts2/CALLCODEIdentity_5Filler.json",
        "https://github.com/ethereum/tests/blob/v17.1/src/GeneralStateTestsFiller/stPreCompiledContracts2/CallIdentity_5Filler.json",
    ],
    pr=["https://github.com/ethereum/execution-spec-tests/pull/1344"],
    coverage_missed_reason="MPT related coverage lost, not relevant to test",
)
@pytest.mark.valid_from("Byzantium")
@pytest.mark.parametrize("call_type", [Op.CALL, Op.CALLCODE])
@pytest.mark.parametrize(
    [
        "call_args",
        "memory_values",
        "call_succeeds",
    ],
    [
        pytest.param(
            CallArgs(gas=0x258, args_size=0xF4240),
            (
                0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF,
            ),
            False,
            id="identity_5",
        ),
        pytest.param(
            CallArgs(gas=0x258, ret_size=0x40),
            (
                0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF,
                0x1234,
            ),
            True,
            id="identity_6",
        ),
    ],
)
def test_call_identity_precompile_large_params(
    state_test: StateTestFiller,
    pre: Alloc,
    call_type: Op,
    call_args: CallArgs,
    memory_values: Tuple[int, ...],
    call_succeeds: bool,
) -> None:
    """Test identity precompile when out of gas occurs."""
    storage = Storage()

    contract_bytecode = generate_identity_call_bytecode(
        storage,
        call_type,
        memory_values,
        call_args,
        call_succeeds,
    )

    account = pre.deploy_contract(
        contract_bytecode,
        storage=storage.canary(),
    )

    tx = Transaction(to=account, sender=pre.fund_eoa())

    post = {account: Account(storage=storage)}

    state_test(pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 4 parametrized test cases across 13 forks.