Skip to content

test_block_full_data()

Documentation for tests/benchmark/test_worst_blocks.py::test_block_full_data@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

fill -v tests/benchmark/test_worst_blocks.py::test_block_full_data -m benchmark

Test a block with empty payload.

Source code in tests/benchmark/test_worst_blocks.py
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
@pytest.mark.parametrize("zero_byte", [True, False])
def test_block_full_data(
    benchmark_test: BenchmarkTestFiller,
    pre: Alloc,
    zero_byte: bool,
    intrinsic_cost: int,
    total_cost_floor_per_token: int,
    gas_benchmark_value: int,
    tx_gas_limit_cap: int,
    total_cost_standard_per_token: int,
    fork: Fork,
) -> None:
    """Test a block with empty payload."""
    iteration_count = math.ceil(gas_benchmark_value / tx_gas_limit_cap)

    gas_remaining = gas_benchmark_value
    total_gas_used = 0
    txs = []
    for _ in range(iteration_count):
        gas_available = min(tx_gas_limit_cap, gas_remaining) - intrinsic_cost
        data = calldata_generator(
            gas_available,
            zero_byte,
            total_cost_floor_per_token,
        )

        total_gas_used += fork.transaction_intrinsic_cost_calculator()(calldata=data)
        gas_remaining -= gas_available + intrinsic_cost

        txs.append(
            Transaction(
                to=pre.fund_eoa(),
                data=data,
                gas_limit=gas_available + intrinsic_cost,
                sender=pre.fund_eoa(),
            )
        )

    benchmark_test(
        blocks=[Block(txs=txs)],
        expected_benchmark_gas_used=total_gas_used,
    )

Parametrized Test Cases

This test case is only parametrized by fork.

Test ID (Abbreviated) zero_byte
...fork_Prague-blockchain_test-zero_byte_True True
...fork_Prague-blockchain_test-zero_byte_False False
...fork_Osaka-blockchain_test-zero_byte_True True
...fork_Osaka-blockchain_test-zero_byte_False False