Skip to content

test_sufficient_balance_blob_tx_pre_fund_tx()

Documentation for tests/cancun/eip4844_blobs/test_blob_txs.py::test_sufficient_balance_blob_tx_pre_fund_tx@20373115.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/cancun/eip4844_blobs/test_blob_txs.py::test_sufficient_balance_blob_tx_pre_fund_tx --fork Amsterdam

Check that transaction is accepted when user can exactly afford the blob gas specified (and max_fee_per_gas would be enough for current block) because a funding transaction is prepended in the same block.

  • Transactions with max fee equal or higher than current block base fee
  • Transactions with and without priority fee
  • Transactions with and without value
  • Transactions with and without calldata
  • Transactions with max fee per blob gas lower or higher than the priority fee
Source code in tests/cancun/eip4844_blobs/test_blob_txs.py
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
@pytest.mark.parametrize_by_fork(
    "blobs_per_tx",
    lambda fork: [
        pytest.param([1], id="single_blob"),
        pytest.param([fork.max_blobs_per_tx()], id="max_blobs"),
    ],
)
@pytest.mark.parametrize(
    "tx_access_list",
    [[], [AccessList(address=100, storage_keys=[100, 200])]],
    ids=["no_access_list", "access_list"],
)
@pytest.mark.parametrize("tx_max_fee_per_gas", [7, 14])
@pytest.mark.parametrize("tx_max_priority_fee_per_gas", [0, 7])
@pytest.mark.parametrize("tx_value", [0, 1])
@pytest.mark.parametrize(
    "tx_calldata",
    [b"", b"\x00", b"\x01"],
    ids=["no_calldata", "single_zero_calldata", "single_one_calldata"],
)
@pytest.mark.parametrize("tx_max_fee_per_blob_gas_multiplier", [1, 100, 10000])
@pytest.mark.parametrize("sender_initial_balance", [0])
@pytest.mark.valid_from("Cancun")
def test_sufficient_balance_blob_tx_pre_fund_tx(
    blockchain_test: BlockchainTestFiller,
    total_account_minimum_balance: int,
    sender: EOA,
    env: Environment,
    pre: Alloc,
    txs: List[Transaction],
    header_verify: Optional[Header],
) -> None:
    """
    Check that transaction is accepted when user can exactly afford the blob
    gas specified (and max_fee_per_gas would be enough for current block)
    because a funding transaction is prepended in the same block.

    - Transactions with max fee equal or higher than current block base fee
    - Transactions with and without priority fee
    - Transactions with and without value
    - Transactions with and without calldata
    - Transactions with max fee per blob gas lower or higher than the priority
        fee
    """
    pre_funding_sender = pre.fund_eoa(
        amount=(21_000 * 100) + total_account_minimum_balance
    )
    txs = [
        Transaction(
            sender=pre_funding_sender,
            to=sender,
            value=total_account_minimum_balance,
            gas_limit=21_000,
        )
    ] + txs
    blockchain_test(
        pre=pre,
        post={},
        blocks=[
            Block(
                txs=txs,
                header_verify=header_verify,
            )
        ],
        genesis_environment=env,
    )

Parametrized Test Cases

This test generates 288 parametrized test cases across 4 forks.