Skip to content

test_invalid_inputs()

Documentation for tests/cancun/eip4844_blobs/test_point_evaluation_precompile.py::test_invalid_inputs@7b8124a7.

Generate fixtures for these test cases for Osaka with:

fill -v tests/cancun/eip4844_blobs/test_point_evaluation_precompile.py::test_invalid_inputs --fork Osaka

Test invalid precompile calls.

  • Out of bounds inputs z and y
  • Correct proof, commitment, z and y, but incorrect lengths
  • Null inputs
  • Zero inputs
  • Correct proof, commitment, z and y, but incorrect version versioned hash
Source code in tests/cancun/eip4844_blobs/test_point_evaluation_precompile.py
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
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
370
371
372
373
374
375
376
377
@pytest.mark.parametrize(
    "z,y,kzg_commitment,kzg_proof,versioned_hash",
    [
        (Spec.BLS_MODULUS, 0, INF_POINT, INF_POINT, None),
        (0, Spec.BLS_MODULUS, INF_POINT, INF_POINT, None),
        (Z, 0, INF_POINT, INF_POINT[:-1], None),
        (Z, 0, INF_POINT, INF_POINT[0:1], None),
        (Z, 0, INF_POINT, INF_POINT + bytes([0]), None),
        (Z, 0, INF_POINT, INF_POINT + bytes([0] * 1023), None),
        (bytes(), bytes(), bytes(), bytes(), bytes()),
        (0, 0, 0, 0, 0),
        (0, 0, 0, 0, None),
        (
            Z,
            0,
            INF_POINT,
            INF_POINT,
            Spec.kzg_to_versioned_hash(0xC0 << 376, 0x00),
        ),
        (
            Z,
            0,
            INF_POINT,
            INF_POINT,
            Spec.kzg_to_versioned_hash(0xC0 << 376, 0x02),
        ),
        (
            Z,
            0,
            INF_POINT,
            INF_POINT,
            Spec.kzg_to_versioned_hash(0xC0 << 376, 0xFF),
        ),
    ],
    ids=[
        "out_of_bounds_z",
        "out_of_bounds_y",
        "correct_proof_1_input_too_short",
        "correct_proof_1_input_too_short_2",
        "correct_proof_1_input_too_long",
        "correct_proof_1_input_extra_long",
        "null_inputs",
        "zeros_inputs",
        "zeros_inputs_correct_versioned_hash",
        "correct_proof_1_incorrect_versioned_hash_version_0x00",
        "correct_proof_1_incorrect_versioned_hash_version_0x02",
        "correct_proof_1_incorrect_versioned_hash_version_0xff",
    ],
)
@pytest.mark.parametrize("result", [Result.FAILURE])
@pytest.mark.valid_from("Cancun")
def test_invalid_inputs(
    state_test: StateTestFiller,
    pre: Alloc,
    tx: Transaction,
    post: Dict,
) -> None:
    """
    Test invalid precompile calls.

    - Out of bounds inputs `z` and `y`
    - Correct proof, commitment, z and y, but incorrect lengths
    - Null inputs
    - Zero inputs
    - Correct proof, commitment, z and y, but incorrect version versioned
       hash
    """
    state_test(
        env=Environment(),
        pre=pre,
        post=post,
        tx=tx,
    )

Parametrized Test Cases

This test generates 12 parametrized test cases across 3 forks.