This repository was archived by the owner on Sep 8, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +83
-15
lines changed Expand file tree Collapse file tree 4 files changed +83
-15
lines changed Original file line number Diff line number Diff line change @@ -78,16 +78,6 @@ def VM(request):
7878 return request .param
7979
8080
81- @pytest .fixture
82- def block_reward (VM ):
83- if VM == ByzantiumVM :
84- return 3 * (10 ** 18 )
85- elif VM == ConstantinopleVM :
86- return 2 * (10 ** 18 )
87- else :
88- return 5 * (10 ** 18 )
89-
90-
9181@pytest .fixture
9282def base_db ():
9383 return AtomicDB ()
Original file line number Diff line number Diff line change 33)
44from tests .core .helpers import (
55 new_transaction ,
6+ # vm_specific_chain,
67)
78
89from eth_utils import (
1516from eth .exceptions import (
1617 InvalidInstruction ,
1718 OutOfGas ,
19+ Revert ,
20+ )
21+
22+ from eth .vm .forks import (
23+ FrontierVM ,
24+ HomesteadVM ,
25+ TangerineWhistleVM ,
26+ SpuriousDragonVM ,
27+ ByzantiumVM ,
28+ ConstantinopleVM ,
1829)
1930
2031
@@ -120,24 +131,87 @@ def test_get_transaction_result(
120131
121132
122133@pytest .mark .parametrize (
123- 'signature, expected' ,
134+ 'vm, signature, expected' ,
124135 (
125136 (
137+ FrontierVM ,
138+ 'doRevert()' ,
139+ InvalidInstruction ,
140+ ),
141+ (
142+ FrontierVM ,
143+ 'useLotsOfGas()' ,
144+ OutOfGas ,
145+ ),
146+
147+ (
148+ HomesteadVM .configure (
149+ support_dao_fork = False ,
150+ ),
151+ 'doRevert()' ,
152+ InvalidInstruction ,
153+ ),
154+ (
155+ HomesteadVM .configure (
156+ support_dao_fork = False ,
157+ ),
158+ 'useLotsOfGas()' ,
159+ OutOfGas ,
160+ ),
161+
162+ (
163+ TangerineWhistleVM ,
164+ 'doRevert()' ,
165+ InvalidInstruction ,
166+ ),
167+ (
168+ TangerineWhistleVM ,
169+ 'useLotsOfGas()' ,
170+ OutOfGas ,
171+ ),
172+
173+ (
174+ SpuriousDragonVM ,
126175 'doRevert()' ,
127176 InvalidInstruction ,
128177 ),
129178 (
179+ SpuriousDragonVM ,
180+ 'useLotsOfGas()' ,
181+ OutOfGas ,
182+ ),
183+
184+ (
185+ ByzantiumVM ,
186+ 'doRevert()' ,
187+ Revert ,
188+ ),
189+ (
190+ ByzantiumVM ,
191+ 'useLotsOfGas()' ,
192+ OutOfGas ,
193+ ),
194+
195+ (
196+ ConstantinopleVM ,
197+ 'doRevert()' ,
198+ Revert ,
199+ ),
200+ (
201+ ConstantinopleVM ,
130202 'useLotsOfGas()' ,
131203 OutOfGas ,
132204 ),
133205 ),
134206)
135207def test_get_transaction_result_revert (
136- chain ,
208+ vm ,
209+ chain_from_vm ,
137210 simple_contract_address ,
138211 signature ,
139212 expected ):
140213
214+ chain = chain_from_vm (vm )
141215 function_selector = function_signature_to_4byte_selector (signature )
142216 call_txn = new_transaction (
143217 chain .get_vm (),
Original file line number Diff line number Diff line change @@ -31,7 +31,8 @@ def new_transaction(
3131 private_key = None ,
3232 gas_price = 10 ,
3333 gas = 100000 ,
34- data = b'' ):
34+ data = b'' ,
35+ chain_id = None ):
3536 """
3637 Create and return a transaction sending amount from <from_> to <to>.
3738
@@ -47,7 +48,10 @@ def new_transaction(
4748 data = data ,
4849 )
4950 if private_key :
50- return tx .as_signed_transaction (private_key , chain_id = 1 )
51+ if chain_id is None :
52+ return tx .as_signed_transaction (private_key )
53+ else :
54+ return tx .as_signed_transaction (private_key , chain_id = chain_id )
5155 else :
5256 return SpoofTransaction (tx , from_ = from_ )
5357
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ def test_mine_block_issues_block_reward(chain):
4747 block = chain .mine_block ()
4848 vm = chain .get_vm ()
4949 coinbase_balance = vm .state .account_db .get_balance (block .header .coinbase )
50- assert coinbase_balance == constants . BLOCK_REWARD
50+ assert coinbase_balance == vm . get_block_reward ()
5151
5252
5353def test_import_block (chain , funded_address , funded_address_private_key ):
You can’t perform that action at this time.
0 commit comments