51
51
_make_call_throws_transaction ,
52
52
_decode_throws_result ,
53
53
)
54
- from .. import (
55
- PyEVMBackend ,
56
- )
57
-
58
54
59
55
PK_A = '0x58d23b55bc9cdce1f18c2500f40ff4ab7245df9a89505e9b1fa4851f623d241d'
60
56
PK_A_ADDRESS = '0xdc544d1aa88ff8bbd2f2aec754b1f1e99e1812fd'
@@ -123,23 +119,24 @@ def _send_and_check_transaction(self, eth_tester, test_transaction, _from):
123
119
self ._check_transactions (transaction , txn )
124
120
125
121
@staticmethod
126
- def _check_transactions (expected_transaction , actual_transaction ):
127
- assert is_same_address (actual_transaction ['from' ], expected_transaction ['from' ])
128
- if 'to' not in expected_transaction or expected_transaction ['to' ] == '' :
122
+ def _check_transactions (sent_transaction , actual_transaction ):
123
+ assert is_same_address (actual_transaction ['from' ], sent_transaction ['from' ])
124
+ if 'to' not in sent_transaction or sent_transaction ['to' ] == '' :
129
125
assert actual_transaction ['to' ] == ''
130
126
else :
131
- assert is_same_address (actual_transaction ['to' ], expected_transaction ['to' ])
127
+ assert is_same_address (actual_transaction ['to' ], sent_transaction ['to' ])
132
128
133
- if expected_transaction .get ('gas_price' ):
134
- assert actual_transaction ['gas_price' ] == expected_transaction ['gas_price' ]
129
+ assert actual_transaction ['gas' ] == sent_transaction ['gas' ]
130
+ assert actual_transaction ['value' ] == sent_transaction ['value' ]
131
+
132
+ if sent_transaction .get ('gas_price' ) is not None :
133
+ assert actual_transaction ['gas_price' ] == sent_transaction ['gas_price' ]
135
134
else :
136
- assert actual_transaction ['max_fee_per_gas' ] == expected_transaction ['max_fee_per_gas' ]
135
+ assert actual_transaction ['max_fee_per_gas' ] == sent_transaction ['max_fee_per_gas' ]
137
136
assert (
138
137
actual_transaction ['max_priority_fee_per_gas' ] ==
139
- expected_transaction ['max_priority_fee_per_gas' ]
138
+ sent_transaction ['max_priority_fee_per_gas' ]
140
139
)
141
- assert actual_transaction ['gas' ] == expected_transaction ['gas' ]
142
- assert actual_transaction ['value' ] == expected_transaction ['value' ]
143
140
144
141
#
145
142
# Testing Flags
@@ -347,12 +344,12 @@ def test_send_transaction_raises_with_legacy_and_dynamic_fee_fields(
347
344
"max_fee_per_gas" : 1000000000 ,
348
345
"max_priority_fee_per_gas" : 1000000000 ,
349
346
}
350
- with pytest .raises (ValidationError ):
347
+ with pytest .raises (ValidationError , match = "legacy and dynamic fee transaction values" ):
351
348
self ._send_and_check_transaction (eth_tester , test_transaction , accounts [0 ])
352
349
353
350
def test_send_transaction_no_gas_price_or_dynamic_fees (self , eth_tester ):
354
351
# test that we default to a dynamic fee transaction which, while pending, will include the
355
- # gas_price as equal to the max_fee_per_gas until that is removed .
352
+ # gas_price as equal to the effective gas price paid .
356
353
accounts = eth_tester .get_accounts ()
357
354
assert accounts , "No accounts available for transaction sending"
358
355
@@ -362,10 +359,11 @@ def test_send_transaction_no_gas_price_or_dynamic_fees(self, eth_tester):
362
359
txn_hash = eth_tester .send_transaction (test_transaction )
363
360
sent_transaction = eth_tester .get_transaction_by_hash (txn_hash )
364
361
365
- assert sent_transaction .get ('gas_price ' ) == 1000000000
362
+ assert sent_transaction .get ('type ' ) == '0x2'
366
363
assert sent_transaction .get ('max_fee_per_gas' ) == 1000000000
367
364
assert sent_transaction .get ('max_priority_fee_per_gas' ) == 1000000000
368
365
assert sent_transaction .get ('access_list' ) == ()
366
+ assert sent_transaction .get ('gas_price' ) == 1000000000
369
367
370
368
def test_send_access_list_transaction (self , eth_tester ):
371
369
accounts = eth_tester .get_accounts ()
@@ -382,7 +380,7 @@ def test_send_access_list_transaction(self, eth_tester):
382
380
}
383
381
txn_hash = eth_tester .send_transaction (access_list_transaction )
384
382
txn = eth_tester .get_transaction_by_hash (txn_hash )
385
- assert eth_tester . get_transaction_receipt ( txn_hash )[ 'type' ] == '0x1'
383
+ assert txn . get ( 'type' ) == '0x1'
386
384
self ._check_transactions (access_list_transaction , txn )
387
385
388
386
# with non-empty access list
@@ -401,7 +399,7 @@ def test_send_access_list_transaction(self, eth_tester):
401
399
)
402
400
txn_hash = eth_tester .send_transaction (access_list_transaction )
403
401
txn = eth_tester .get_transaction_by_hash (txn_hash )
404
- assert eth_tester . get_transaction_receipt ( txn_hash )[ 'type' ] == '0x1'
402
+ assert txn . get ( 'type' ) == '0x1'
405
403
self ._check_transactions (access_list_transaction , txn )
406
404
407
405
def test_send_dynamic_fee_transaction (self , eth_tester ):
@@ -419,7 +417,7 @@ def test_send_dynamic_fee_transaction(self, eth_tester):
419
417
}
420
418
txn_hash = eth_tester .send_transaction (dynamic_fee_transaction )
421
419
txn = eth_tester .get_transaction_by_hash (txn_hash )
422
- assert eth_tester . get_transaction_receipt ( txn_hash )[ 'type' ] == '0x2'
420
+ assert txn . get ( 'type' ) == '0x2'
423
421
self ._check_transactions (dynamic_fee_transaction , txn )
424
422
425
423
# with non-empty access list
@@ -438,7 +436,7 @@ def test_send_dynamic_fee_transaction(self, eth_tester):
438
436
)
439
437
txn_hash = eth_tester .send_transaction (dynamic_fee_transaction )
440
438
txn = eth_tester .get_transaction_by_hash (txn_hash )
441
- assert eth_tester . get_transaction_receipt ( txn_hash )[ 'type' ] == '0x2'
439
+ assert txn . get ( 'type' ) == '0x2'
442
440
self ._check_transactions (dynamic_fee_transaction , txn )
443
441
444
442
def test_block_number_auto_mine_transactions_enabled (self , eth_tester ):
@@ -648,7 +646,6 @@ def test_get_block_by_hash(self, eth_tester):
648
646
block = eth_tester .get_block_by_hash (block_hash )
649
647
assert block ['number' ] == block_number
650
648
assert block ['hash' ] == block_hash
651
- assert block ['base_fee_per_gas' ] is not None
652
649
653
650
def test_get_block_by_hash_full_transactions (self , eth_tester ):
654
651
eth_tester .mine_blocks (2 )
@@ -730,30 +727,17 @@ def test_get_transaction_by_hash_for_unmined_transaction(self, eth_tester):
730
727
assert transaction ['hash' ] == transaction_hash
731
728
assert transaction ['block_hash' ] is None
732
729
733
- def test_get_transaction_receipt_for_unmined_transaction_raises (self , eth_tester ):
734
- eth_tester .disable_auto_mine_transactions ()
735
- transaction_hash = eth_tester .send_transaction ({
736
- "from" : eth_tester .get_accounts ()[0 ],
737
- "to" : BURN_ADDRESS ,
738
- "gas" : 21000 ,
739
- })
740
- with pytest .raises (TransactionNotFound ):
741
- eth_tester .get_transaction_receipt (transaction_hash )
742
-
743
730
def test_get_transaction_receipt_for_mined_transaction (self , eth_tester ):
744
731
transaction_hash = eth_tester .send_transaction ({
745
732
"from" : eth_tester .get_accounts ()[0 ],
746
733
"to" : BURN_ADDRESS ,
747
734
"gas" : 21000 ,
748
735
})
749
- mined_transaction = eth_tester .get_transaction_by_hash (transaction_hash )
750
- max_fee = mined_transaction ['max_fee_per_gas' ]
751
- assert max_fee == 1000000000
752
736
753
737
receipt = eth_tester .get_transaction_receipt (transaction_hash )
754
738
assert receipt ['transaction_hash' ] == transaction_hash
755
739
assert receipt ['type' ] == '0x2'
756
- assert receipt ['effective_gas_price' ] == max_fee
740
+ assert receipt ['effective_gas_price' ] == 1000000000
757
741
758
742
@pytest .mark .parametrize (
759
743
'type_specific_params,_type' ,
@@ -815,7 +799,7 @@ def test_receipt_effective_gas_price_for_mined_transaction_legacy(self, eth_test
815
799
assert receipt ['type' ] == '0x0'
816
800
assert receipt ['effective_gas_price' ] == gas_price
817
801
818
- def test_receipt_effective_gas_price_for_mined_transaction_base_fee_limit (self , eth_tester ):
802
+ def test_receipt_effective_gas_price_for_mined_transaction_base_fee_minimum (self , eth_tester ):
819
803
priority_fee = 1500000000
820
804
821
805
transaction_hash = eth_tester .send_transaction ({
@@ -838,7 +822,7 @@ def test_receipt_effective_gas_price_for_mined_transaction_base_fee_limit(self,
838
822
# effective gas price
839
823
assert receipt ['effective_gas_price' ] == base_fee + priority_fee
840
824
841
- def test_receipt_effective_gas_price_for_mined_transaction_max_fee_limit (self , eth_tester ):
825
+ def test_receipt_effective_gas_price_for_mined_transaction_max_fee_minimum (self , eth_tester ):
842
826
priority_fee = 1500000000
843
827
max_fee = priority_fee + 1 # arbitrary, to differentiate from the priority fee
844
828
@@ -862,6 +846,16 @@ def test_receipt_effective_gas_price_for_mined_transaction_max_fee_limit(self, e
862
846
# effective gas price
863
847
assert receipt ['effective_gas_price' ] == max_fee
864
848
849
+ def test_get_transaction_receipt_for_unmined_transaction_raises (self , eth_tester ):
850
+ eth_tester .disable_auto_mine_transactions ()
851
+ transaction_hash = eth_tester .send_transaction ({
852
+ "from" : eth_tester .get_accounts ()[0 ],
853
+ "to" : BURN_ADDRESS ,
854
+ "gas" : 21000 ,
855
+ })
856
+ with pytest .raises (TransactionNotFound ):
857
+ eth_tester .get_transaction_receipt (transaction_hash )
858
+
865
859
def test_call_return13 (self , eth_tester ):
866
860
self .skip_if_no_evm_execution ()
867
861
@@ -1525,16 +1519,8 @@ def test_delete_filter(self, eth_tester):
1525
1519
def test_receipt_gas_used_computation (self , eth_tester ):
1526
1520
eth_tester .disable_auto_mine_transactions ()
1527
1521
1528
- if isinstance (eth_tester .backend , PyEVMBackend ):
1529
- chain_id = eth_tester .backend .chain .chain_id
1530
-
1531
1522
tx_hashes = []
1532
1523
for i in range (4 ):
1533
- # TODO: PyEvm backend was not consistent in keeping the chain_id, so reset it. This
1534
- # needs to be investigated further.
1535
- if isinstance (eth_tester .backend , PyEVMBackend ):
1536
- eth_tester .backend .chain .chain_id = chain_id
1537
-
1538
1524
tx = {
1539
1525
'from' : eth_tester .get_accounts ()[i ],
1540
1526
'to' : eth_tester .get_accounts ()[i + 1 ],
0 commit comments