Skip to content

Commit 8bf9c34

Browse files
marioevzspencer-tb
andauthored
feat(specs,tests): exception_test marker (ethereum#1436)
* feat(specs): Introduce/enforce `negative` marker * feat(tests): Add marker to all invalid transaction/block tests * changelog * refactor(specs): Rename marker to `pytest.mark.exception_test` * refactor(tests): Rename marker to `pytest.mark.exception_test` * refactor(specs): Make `request` a `PrivateAttr` * nit * fix(specs): Review suggestions Co-authored-by: spencer <spencer.taylor-brown@ethereum.org> --------- Co-authored-by: spencer <spencer.taylor-brown@ethereum.org>
1 parent 806548c commit 8bf9c34

14 files changed

Lines changed: 53 additions & 8 deletions

File tree

cancun/eip4844_blobs/test_blob_txs.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ def generate_invalid_tx_max_fee_per_blob_gas_tests(
424424
min_base_fee_per_blob_gas, # tx max_blob_gas_cost is the minimum
425425
TransactionException.INSUFFICIENT_MAX_FEE_PER_BLOB_GAS,
426426
id="insufficient_max_fee_per_blob_gas",
427+
marks=pytest.mark.exception_test,
427428
)
428429
)
429430
if (next_base_fee_per_blob_gas - min_base_fee_per_blob_gas) > 1:
@@ -436,6 +437,7 @@ def generate_invalid_tx_max_fee_per_blob_gas_tests(
436437
- 1, # tx max_blob_gas_cost is one less than the minimum
437438
TransactionException.INSUFFICIENT_MAX_FEE_PER_BLOB_GAS,
438439
id="insufficient_max_fee_per_blob_gas_one_less_than_next",
440+
marks=pytest.mark.exception_test,
439441
)
440442
)
441443
if min_base_fee_per_blob_gas > 1:
@@ -446,6 +448,7 @@ def generate_invalid_tx_max_fee_per_blob_gas_tests(
446448
min_base_fee_per_blob_gas - 1, # tx max_blob_gas_cost is one less than the minimum
447449
TransactionException.INSUFFICIENT_MAX_FEE_PER_BLOB_GAS,
448450
id="insufficient_max_fee_per_blob_gas_one_less_than_min",
451+
marks=pytest.mark.exception_test,
449452
)
450453
)
451454

@@ -456,6 +459,7 @@ def generate_invalid_tx_max_fee_per_blob_gas_tests(
456459
0, # tx max_blob_gas_cost is 0
457460
TransactionException.INSUFFICIENT_MAX_FEE_PER_BLOB_GAS,
458461
id="invalid_max_fee_per_blob_gas",
462+
marks=pytest.mark.exception_test,
459463
)
460464
)
461465
return tests
@@ -533,6 +537,7 @@ def test_invalid_tx_max_fee_per_blob_gas_state(
533537
],
534538
ids=["insufficient_max_fee_per_gas"],
535539
)
540+
@pytest.mark.exception_test
536541
@pytest.mark.valid_from("Cancun")
537542
def test_invalid_normal_gas(
538543
state_test: StateTestFiller,
@@ -572,6 +577,7 @@ def test_invalid_normal_gas(
572577
],
573578
ids=[""],
574579
)
580+
@pytest.mark.exception_test
575581
@pytest.mark.valid_from("Cancun")
576582
def test_invalid_block_blob_count(
577583
blockchain_test: BlockchainTestFiller,
@@ -611,6 +617,7 @@ def test_invalid_block_blob_count(
611617
@pytest.mark.parametrize("tx_max_fee_per_blob_gas_multiplier", [1, 100, 10000])
612618
@pytest.mark.parametrize("account_balance_modifier", [-1], ids=["exact_balance_minus_1"])
613619
@pytest.mark.parametrize("tx_error", [TransactionException.INSUFFICIENT_ACCOUNT_FUNDS], ids=[""])
620+
@pytest.mark.exception_test
614621
@pytest.mark.valid_from("Cancun")
615622
def test_insufficient_balance_blob_tx(
616623
state_test: StateTestFiller,
@@ -831,6 +838,7 @@ def test_blob_gas_subtraction_tx(
831838
)
832839
@pytest.mark.parametrize("account_balance_modifier", [-1], ids=["exact_balance_minus_1"])
833840
@pytest.mark.parametrize("tx_error", [TransactionException.INSUFFICIENT_ACCOUNT_FUNDS], ids=[""])
841+
@pytest.mark.exception_test
834842
@pytest.mark.valid_from("Cancun")
835843
def test_insufficient_balance_blob_tx_combinations(
836844
blockchain_test: BlockchainTestFiller,
@@ -877,6 +885,7 @@ def generate_invalid_tx_blob_count_tests(
877885
"blobs_per_tx,tx_error",
878886
generate_invalid_tx_blob_count_tests,
879887
)
888+
@pytest.mark.exception_test
880889
@pytest.mark.valid_from("Cancun")
881890
def test_invalid_tx_blob_count(
882891
state_test: StateTestFiller,
@@ -921,6 +930,7 @@ def test_invalid_tx_blob_count(
921930
@pytest.mark.parametrize(
922931
"tx_error", [TransactionException.TYPE_3_TX_INVALID_BLOB_VERSIONED_HASH], ids=[""]
923932
)
933+
@pytest.mark.exception_test
924934
@pytest.mark.valid_from("Cancun")
925935
def test_invalid_blob_hash_versioning_single_tx(
926936
state_test: StateTestFiller,
@@ -979,6 +989,7 @@ def test_invalid_blob_hash_versioning_single_tx(
979989
@pytest.mark.parametrize(
980990
"tx_error", [TransactionException.TYPE_3_TX_INVALID_BLOB_VERSIONED_HASH], ids=[""]
981991
)
992+
@pytest.mark.exception_test
982993
@pytest.mark.valid_from("Cancun")
983994
def test_invalid_blob_hash_versioning_multiple_txs(
984995
blockchain_test: BlockchainTestFiller,
@@ -1005,6 +1016,7 @@ def test_invalid_blob_hash_versioning_multiple_txs(
10051016
@pytest.mark.parametrize(
10061017
"tx_gas", [500_000], ids=[""]
10071018
) # Increase gas to account for contract creation
1019+
@pytest.mark.exception_test
10081020
@pytest.mark.valid_from("Cancun")
10091021
def test_invalid_blob_tx_contract_creation(
10101022
blockchain_test: BlockchainTestFiller,
@@ -1347,6 +1359,7 @@ def test_blob_tx_attribute_gasprice_opcode(
13471359
],
13481360
ids=["no_blob_tx", "one_blob_tx"],
13491361
)
1362+
@pytest.mark.exception_test
13501363
@pytest.mark.valid_at_transition_to("Cancun")
13511364
def test_blob_type_tx_pre_fork(
13521365
state_test: StateTestFiller,

cancun/eip4844_blobs/test_blob_txs_full.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ def generate_full_blob_tests(
293293
"txs_blobs,txs_wrapped_blobs",
294294
generate_full_blob_tests,
295295
)
296+
@pytest.mark.exception_test
296297
@pytest.mark.valid_from("Cancun")
297298
def test_reject_valid_full_blob_in_block_rlp(
298299
blockchain_test: BlockchainTestFiller,

cancun/eip4844_blobs/test_excess_blob_gas.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ def test_correct_decreasing_blob_gas_costs(
387387
"parent_blobs",
388388
lambda fork: range(0, fork.max_blobs_per_block() + 1),
389389
)
390+
@pytest.mark.exception_test
390391
def test_invalid_zero_excess_blob_gas_in_header(
391392
blockchain_test: BlockchainTestFiller,
392393
env: Environment,
@@ -435,6 +436,7 @@ def all_invalid_blob_gas_used_combinations(fork: Fork) -> Iterator[Tuple[int, in
435436
all_invalid_blob_gas_used_combinations,
436437
)
437438
@pytest.mark.parametrize("parent_blobs", [0])
439+
@pytest.mark.exception_test
438440
def test_invalid_blob_gas_used_in_header(
439441
blockchain_test: BlockchainTestFiller,
440442
env: Environment,
@@ -479,6 +481,7 @@ def generate_invalid_excess_blob_gas_above_target_change_tests(fork: Fork) -> Li
479481
generate_invalid_excess_blob_gas_above_target_change_tests,
480482
)
481483
@pytest.mark.parametrize("new_blobs", [1])
484+
@pytest.mark.exception_test
482485
def test_invalid_excess_blob_gas_above_target_change(
483486
blockchain_test: BlockchainTestFiller,
484487
env: Environment,
@@ -523,6 +526,7 @@ def test_invalid_excess_blob_gas_above_target_change(
523526
"parent_excess_blobs", lambda fork: [1, fork.target_blobs_per_block()]
524527
)
525528
@pytest.mark.parametrize("new_blobs", [1])
529+
@pytest.mark.exception_test
526530
def test_invalid_static_excess_blob_gas(
527531
blockchain_test: BlockchainTestFiller,
528532
env: Environment,
@@ -564,6 +568,7 @@ def test_invalid_static_excess_blob_gas(
564568
)
565569
@pytest.mark.parametrize("parent_excess_blobs", [0]) # Start at 0
566570
@pytest.mark.parametrize("new_blobs", [1])
571+
@pytest.mark.exception_test
567572
def test_invalid_excess_blob_gas_target_blobs_increase_from_zero(
568573
blockchain_test: BlockchainTestFiller,
569574
env: Environment,
@@ -605,6 +610,7 @@ def test_invalid_excess_blob_gas_target_blobs_increase_from_zero(
605610
)
606611
@pytest.mark.parametrize("parent_excess_blobs", [0]) # Start at 0
607612
@pytest.mark.parametrize("new_blobs", [1])
613+
@pytest.mark.exception_test
608614
def test_invalid_static_excess_blob_gas_from_zero_on_blobs_above_target(
609615
blockchain_test: BlockchainTestFiller,
610616
env: Environment,
@@ -653,6 +659,7 @@ def test_invalid_static_excess_blob_gas_from_zero_on_blobs_above_target(
653659
),
654660
)
655661
@pytest.mark.parametrize("new_blobs", [1])
662+
@pytest.mark.exception_test
656663
def test_invalid_excess_blob_gas_change(
657664
blockchain_test: BlockchainTestFiller,
658665
env: Environment,
@@ -704,6 +711,7 @@ def test_invalid_excess_blob_gas_change(
704711
"parent_excess_blobs",
705712
lambda fork: range(fork.target_blobs_per_block()),
706713
)
714+
@pytest.mark.exception_test
707715
def test_invalid_negative_excess_blob_gas(
708716
blockchain_test: BlockchainTestFiller,
709717
env: Environment,
@@ -753,6 +761,7 @@ def test_invalid_negative_excess_blob_gas(
753761
"parent_excess_blobs",
754762
lambda fork: [fork.target_blobs_per_block() + 1],
755763
)
764+
@pytest.mark.exception_test
756765
def test_invalid_non_multiple_excess_blob_gas(
757766
blockchain_test: BlockchainTestFiller,
758767
env: Environment,

cancun/eip4844_blobs/test_excess_blob_gas_fork_transition.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ def post( # noqa: D103
213213
(True, True),
214214
],
215215
)
216+
@pytest.mark.exception_test
216217
def test_invalid_pre_fork_block_with_blob_fields(
217218
blockchain_test: BlockchainTestFiller,
218219
env: Environment,
@@ -257,6 +258,7 @@ def test_invalid_pre_fork_block_with_blob_fields(
257258
(True, True),
258259
],
259260
)
261+
@pytest.mark.exception_test
260262
def test_invalid_post_fork_block_without_blob_fields(
261263
blockchain_test: BlockchainTestFiller,
262264
env: Environment,

prague/eip6110_deposits/test_deposits.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,7 @@ def test_deposit(
951951
),
952952
],
953953
)
954+
@pytest.mark.exception_test
954955
def test_deposit_negative(
955956
blockchain_test: BlockchainTestFiller,
956957
pre: Alloc,

prague/eip7002_el_triggerable_withdrawals/test_withdrawal_requests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,7 @@ def test_withdrawal_requests(
679679
),
680680
],
681681
)
682+
@pytest.mark.exception_test
682683
def test_withdrawal_requests_negative(
683684
pre: Alloc,
684685
fork: Fork,

prague/eip7251_consolidations/test_consolidations.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ def test_consolidation_requests(
730730
),
731731
],
732732
)
733+
@pytest.mark.exception_test
733734
def test_consolidation_requests_negative(
734735
pre: Alloc,
735736
fork: Fork,

prague/eip7623_increase_calldata_cost/test_transaction_validity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
# the data floor does not consume more gas than it should.
3838
pytest.param(1, id="extra_gas"),
3939
pytest.param(0, id="exact_gas"),
40-
pytest.param(-1, id="insufficient_gas"),
40+
pytest.param(-1, id="insufficient_gas", marks=pytest.mark.exception_test),
4141
],
4242
),
4343
pytest.mark.parametrize(

prague/eip7685_general_purpose_el_requests/test_multi_type_requests.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ def invalid_requests_block_combinations(fork: Fork) -> List[ParameterSet]:
604604
"requests,block_body_override_requests,exception",
605605
invalid_requests_block_combinations,
606606
)
607+
@pytest.mark.exception_test
607608
def test_invalid_deposit_withdrawal_consolidation_requests(
608609
blockchain_test: BlockchainTestFiller,
609610
pre: Alloc,
@@ -631,6 +632,7 @@ def test_invalid_deposit_withdrawal_consolidation_requests(
631632
)
632633
@pytest.mark.parametrize("correct_requests_hash_in_header", [True])
633634
@pytest.mark.blockchain_test_engine_only
635+
@pytest.mark.exception_test
634636
def test_invalid_deposit_withdrawal_consolidation_requests_engine(
635637
blockchain_test: BlockchainTestFiller,
636638
pre: Alloc,

prague/eip7702_set_code_tx/test_gas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ def test_account_warming(
894894
@pytest.mark.parametrize(**gas_test_parameter_args(include_pre_authorized=False))
895895
@pytest.mark.parametrize(
896896
"valid",
897-
[True, False],
897+
[True, pytest.param(False, marks=pytest.mark.exception_test)],
898898
)
899899
def test_intrinsic_gas_cost(
900900
state_test: StateTestFiller,

0 commit comments

Comments
 (0)