@pytest.mark.inclusion_test
@pytest.mark.parametrize(
**gas_test_parameter_args(include_pre_authorized=False)
)
@pytest.mark.parametrize(
"valid",
[True, pytest.param(False, marks=pytest.mark.exception_test)],
)
def test_intrinsic_gas_cost(
state_test: StateTestFiller,
pre: Alloc,
fork: Fork,
authorization_list: List[AuthorizationTuple],
data: bytes,
access_list: List[AccessList],
sender: EOA,
valid: bool,
) -> None:
"""
Test sending a transaction with the exact intrinsic gas required and also
insufficient gas.
"""
# Calculate the intrinsic gas cost of the authorizations, by default the
# full empty account cost is charged for each authorization.
intrinsic_gas = fork.transaction_intrinsic_cost_calculator()(
calldata=data,
access_list=access_list,
authorization_list_or_count=authorization_list,
)
tx_gas = intrinsic_gas
if not valid:
tx_gas -= 1
test_code = Op.STOP
test_code_address = pre.deploy_contract(test_code)
tx = Transaction(
gas_limit=tx_gas,
to=test_code_address,
value=0,
data=data,
authorization_list=authorization_list,
access_list=access_list,
sender=sender,
error=TransactionException.INTRINSIC_GAS_TOO_LOW
if not valid
else None,
)
state_test(
pre=pre,
tx=tx,
post={},
)