Skip to content

test_ether_transfers_to_precompile()

Documentation for tests/benchmark/compute/scenario/test_transaction_types.py::test_ether_transfers_to_precompile@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/benchmark/compute/scenario/test_transaction_types.py::test_ether_transfers_to_precompile --gas-benchmark-values 1

Test a block full of ether transfers to a precompile address.

Source code in tests/benchmark/compute/scenario/test_transaction_types.py
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
@pytest.mark.with_all_precompiles
@pytest.mark.parametrize("transfer_amount", [0, 1])
def test_ether_transfers_to_precompile(
    benchmark_test: BenchmarkTestFiller,
    pre: Alloc,
    precompile: int,
    gas_benchmark_value: int,
    transfer_amount: int,
    intrinsic_cost: int,
) -> None:
    """Test a block full of ether transfers to a precompile address."""
    iteration_count = gas_benchmark_value // intrinsic_cost
    txs = []
    for _ in range(iteration_count):
        txs.append(
            Transaction(
                to=Address(precompile),
                value=transfer_amount,
                gas_limit=intrinsic_cost,
                sender=pre.fund_eoa(),
            )
        )

    benchmark_test(
        pre=pre,
        blocks=[Block(txs=txs)],
        expected_benchmark_gas_used=iteration_count * intrinsic_cost,
    )

Parametrized Test Cases

This test generates 36 parametrized test cases across 3 forks.