Skip to content

test_set_code_transaction_fee_validations()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_transaction_fee_validations@724131d1.

Generate fixtures for these test cases for Prague with:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_transaction_fee_validations --fork Prague

Test that a transaction with an insufficient max fee per gas is rejected.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs.py
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
@pytest.mark.parametrize(
    "max_fee_per_gas, max_priority_fee_per_gas, expected_error",
    [
        (6, 0, TransactionException.INSUFFICIENT_MAX_FEE_PER_GAS),
        (7, 8, TransactionException.PRIORITY_GREATER_THAN_MAX_FEE_PER_GAS),
    ],
    ids=[
        "insufficient_max_fee_per_gas",
        "priority_greater_than_max_fee_per_gas",
    ],
)
@pytest.mark.exception_test
def test_set_code_transaction_fee_validations(
    state_test: StateTestFiller,
    pre: Alloc,
    max_fee_per_gas: int,
    max_priority_fee_per_gas: int,
    expected_error: TransactionException,
):
    """Test that a transaction with an insufficient max fee per gas is rejected."""
    set_to_code = pre.deploy_contract(Op.STOP)
    auth_signer = pre.fund_eoa(amount=0)
    tx = Transaction(
        sender=pre.fund_eoa(),
        gas_limit=500_000,
        to=auth_signer,
        value=0,
        max_fee_per_gas=max_fee_per_gas,
        max_priority_fee_per_gas=max_priority_fee_per_gas,
        authorization_list=[
            AuthorizationTuple(
                address=set_to_code,
                nonce=0,
                signer=auth_signer,
            ),
        ],
        error=expected_error,
    )

    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post={},
    )

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) max_fee_per_gas max_priority_fee_per_gas expected_error
...fork_Prague-state_test-insufficient_max_fee_per_gas 6 0 TransactionException.INSUFFICIENT_MAX_FEE_PER_GAS
...fork_Prague-state_test-priority_greater_than_max_fee_per_gas 7 8 TransactionException.PRIORITY_GREATER_THAN_MAX_FEE_PER_GAS
...fork_Prague-blockchain_test_from_state_test-insufficient_max_fee_per_gas 6 0 TransactionException.INSUFFICIENT_MAX_FEE_PER_GAS
...fork_Prague-blockchain_test_from_state_test-priority_greater_than_max_fee_per_gas 7 8 TransactionException.PRIORITY_GREATER_THAN_MAX_FEE_PER_GAS
...fork_Osaka-state_test-insufficient_max_fee_per_gas 6 0 TransactionException.INSUFFICIENT_MAX_FEE_PER_GAS
...fork_Osaka-state_test-priority_greater_than_max_fee_per_gas 7 8 TransactionException.PRIORITY_GREATER_THAN_MAX_FEE_PER_GAS
...fork_Osaka-blockchain_test_from_state_test-insufficient_max_fee_per_gas 6 0 TransactionException.INSUFFICIENT_MAX_FEE_PER_GAS
...fork_Osaka-blockchain_test_from_state_test-priority_greater_than_max_fee_per_gas 7 8 TransactionException.PRIORITY_GREATER_THAN_MAX_FEE_PER_GAS