Skip to content

test_multiple_refund_types_in_one_tx()

Documentation for tests/amsterdam/eip7778_block_gas_accounting_without_refunds/test_gas_accounting.py::test_multiple_refund_types_in_one_tx@87aba1a3.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7778_block_gas_accounting_without_refunds/test_gas_accounting.py::test_multiple_refund_types_in_one_tx --fork Amsterdam

Test gas accounting for all refund types available in the given fork.

Source code in tests/amsterdam/eip7778_block_gas_accounting_without_refunds/test_gas_accounting.py
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
@pytest.mark.parametrize(
    "refund_tx_reverts",
    [
        pytest.param(True, id="refund_tx_reverts"),
        pytest.param(False, id=""),
    ],
)
@pytest.mark.execute(pytest.mark.skip(reason="Requires specific gas price"))
@pytest.mark.valid_from("Amsterdam")
def test_multiple_refund_types_in_one_tx(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    fork: Fork,
    refund_tx_reverts: bool,
) -> None:
    """Test gas accounting for all refund types available in the given fork."""
    refunds_count = 10

    post = Alloc()
    refund_types = set(fork.refund_types())

    (
        _,
        gas_used_pre_refund,
        tx_state_gas,
        call_data_floor_cost,
        refund_tx,
    ) = build_refund_tx(
        fork=fork,
        pre=pre,
        post=post,
        refund_types=refund_types,
        refunds_count=refunds_count,
        refund_tx_reverts=refund_tx_reverts,
    )

    # EIP-8037: block gas_used = max(block_regular_gas, block_state_gas),
    # with the calldata floor binding the regular dimension.
    block_regular = max(gas_used_pre_refund, call_data_floor_cost)
    refund_tx_block_gas_used = max(block_regular, tx_state_gas)

    blockchain_test(
        pre=pre,
        blocks=[
            Block(
                txs=[refund_tx],
                expected_gas_used=refund_tx_block_gas_used,
            )
        ],
        post=post,
    )

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.