Skip to content

Commit 464b83a

Browse files
committed
feat(tests): Add blob gas subtraction order tests.
1 parent 0e7c0f8 commit 464b83a

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

tests/cancun/eip4844_blobs/test_blob_txs.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,59 @@ def test_sufficient_balance_blob_tx_pre_fund_tx(
892892
)
893893

894894

895+
@pytest.mark.parametrize(
896+
"tx_access_list",
897+
[[], [AccessList(address=100, storage_keys=[100, 200])]],
898+
ids=["no_access_list", "access_list"],
899+
)
900+
@pytest.mark.parametrize("tx_max_fee_per_gas", [7, 14])
901+
@pytest.mark.parametrize("tx_max_priority_fee_per_gas", [0, 7])
902+
@pytest.mark.parametrize("tx_value", [0, 1])
903+
@pytest.mark.parametrize(
904+
"tx_calldata",
905+
[b"", b"\x00", b"\x01"],
906+
ids=["no_calldata", "single_zero_calldata"],
907+
)
908+
@pytest.mark.parametrize("tx_max_fee_per_blob_gas", [1, 100])
909+
@pytest.mark.parametrize(
910+
"tx_gas", [500_000], ids=[""]
911+
) # Increase gas to account for contract code
912+
@pytest.mark.parametrize("mid_tx_send_amount", [0, 100])
913+
@pytest.mark.valid_from("Cancun")
914+
def test_blob_gas_subtraction_tx(
915+
state_test: StateTestFiller,
916+
state_env: Environment,
917+
pre: Dict,
918+
txs: List[Transaction],
919+
destination_account: str,
920+
mid_tx_send_amount: int,
921+
):
922+
"""
923+
Check that the blob gas fee for a transaction is subtracted from the sender balance before the
924+
transaction is executed, including:
925+
926+
- Transactions with max fee equal or higher than current block base fee
927+
- Transactions with and without priority fee
928+
- Transactions with and without value
929+
- Transactions with and without calldata
930+
- Transactions with max fee per blob gas lower or higher than the priority fee
931+
- Transactions where an externally owned account sends funds to the sender mid execution
932+
"""
933+
assert len(txs) == 1
934+
pre[destination_account] = Account(
935+
balance=mid_tx_send_amount,
936+
code=Op.SSTORE(0, Op.BALANCE(Op.ORIGIN))
937+
+ Op.CALL(Op.GAS, Op.ORIGIN, mid_tx_send_amount, 0, 0, 0, 0)
938+
+ Op.SSTORE(1, Op.BALANCE(Op.ORIGIN)),
939+
)
940+
state_test(
941+
pre=pre,
942+
post={},
943+
tx=txs[0],
944+
env=state_env,
945+
)
946+
947+
895948
@pytest.mark.parametrize(
896949
"blobs_per_tx",
897950
all_valid_blob_combinations(),

0 commit comments

Comments
 (0)