Skip to content

test_precompile_during_fork()

Documentation for tests/cancun/eip4844_blobs/test_point_evaluation_precompile.py::test_precompile_during_fork@ffe48572.

Generate fixtures for these test cases for Cancun with:

fill -v tests/cancun/eip4844_blobs/test_point_evaluation_precompile.py::test_precompile_during_fork --fork Cancun

Test calling the Point Evaluation Precompile during the appropriate fork.

Source code in tests/cancun/eip4844_blobs/test_point_evaluation_precompile.py
@pytest.mark.parametrize(
    "z,y,kzg_commitment,kzg_proof,versioned_hash",
    [[Z, 0, INF_POINT, INF_POINT, None]],
    ids=["correct_proof"],
)
@pytest.mark.parametrize("precompile_caller_storage", [{}], ids=[""])
@pytest.mark.parametrize(
    "precompile_caller_balance", [len(PRE_FORK_BLOCK_RANGE)], ids=[""]
)
@pytest.mark.parametrize(
    "precompile_caller_code",
    [
        Op.CALLDATACOPY(0, 0, Op.CALLDATASIZE)
        + Op.SSTORE(
            Op.NUMBER,
            Op.CALL(
                address=Spec.POINT_EVALUATION_PRECOMPILE_ADDRESS,
                value=1,
                args_size=Op.CALLDATASIZE,
            ),
        )
    ],
    ids=[""],
)
@pytest.mark.valid_at_transition_to("Cancun")
def test_precompile_during_fork(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    precompile_caller_address: Address,
    precompile_input: bytes,
    sender: EOA,
) -> None:
    """
    Test calling the Point Evaluation Precompile during the appropriate fork.
    """
    # Blocks before fork
    blocks = [
        Block(
            timestamp=t,
            txs=[
                Transaction(
                    sender=sender,
                    data=precompile_input,
                    to=precompile_caller_address,
                )
            ],
        )
        for t in PRE_FORK_BLOCK_RANGE
    ]
    # Block after fork
    blocks += [
        Block(
            timestamp=FORK_TIMESTAMP,
            txs=[
                Transaction(
                    sender=sender,
                    data=precompile_input,
                    to=precompile_caller_address,
                )
            ],
        )
    ]

    post = {
        precompile_caller_address: Account(
            storage=dict.fromkeys(range(1, len(PRE_FORK_BLOCK_RANGE) + 1), 1),
            # Only the call in the last block's tx fails; storage 0 by default.
        ),
        Address(Spec.POINT_EVALUATION_PRECOMPILE_ADDRESS): Account(
            balance=len(PRE_FORK_BLOCK_RANGE),
        ),
    }

    blockchain_test(
        pre=pre,
        post=post,
        blocks=blocks,
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.