Skip to content

test_modexp_used_in_transaction_entry_points()

Documentation for tests/osaka/eip7883_modexp_gas_increase/test_modexp_thresholds.py::test_modexp_used_in_transaction_entry_points@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/osaka/eip7883_modexp_gas_increase/test_modexp_thresholds.py::test_modexp_used_in_transaction_entry_points --fork Amsterdam

Test ModExp using in transaction entry points with different precompile gas modifiers.

Source code in tests/osaka/eip7883_modexp_gas_increase/test_modexp_thresholds.py
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
@pytest.mark.parametrize(
    "modexp_input,modexp_expected,precompile_gas_modifier,call_values,call_succeeds",
    [
        pytest.param(
            Spec.modexp_input,
            Spec.modexp_expected,
            1,
            0,
            True,
            id="extra_gas",
        ),
        pytest.param(
            Spec.modexp_input,
            Spec.modexp_expected,
            0,
            0,
            True,
            id="exact_gas",
        ),
        pytest.param(
            Spec.modexp_input,
            Spec.modexp_expected,
            0,
            1000,
            True,
            id="extra_value",
        ),
        pytest.param(
            Spec.modexp_input,
            Spec.modexp_error,
            -1,
            0,
            False,
            id="insufficient_gas",
        ),
    ],
)
@EIPChecklist.Precompile.Test.CallContexts.TxEntry()
@EIPChecklist.Precompile.Test.ValueTransfer.NoFee()
@pytest.mark.valid_from("Berlin")
@pytest.mark.eels_base_coverage
def test_modexp_used_in_transaction_entry_points(
    state_test: StateTestFiller,
    pre: Alloc,
    tx: Transaction,
    modexp_input: bytes,
    tx_gas_limit: int,
    call_values: int,
) -> None:
    """
    Test ModExp using in transaction entry points with different precompile gas
    modifiers.
    """
    tx = Transaction(
        to=Spec.MODEXP_ADDRESS,
        sender=pre.fund_eoa(),
        data=bytes(modexp_input),
        gas_limit=tx_gas_limit,
        value=call_values,
    )
    state_test(pre=pre, tx=tx, post={})

Parametrized Test Cases

This test generates 4 parametrized test cases across 8 forks.