14
14
CONTRACTS_DIR = path .join (path .dirname (__file__ ), 'contracts' )
15
15
16
16
17
+ def bytecode_is_generated (cinfo , cname ):
18
+ return 'code' in cinfo [cname ] and len (cinfo [cname ]['code' ]) > 10
19
+
17
20
@pytest .mark .skipif (not SOLIDITY_AVAILABLE , reason = 'solc compiler not available' )
18
21
def test_library_from_file ():
19
22
state = tester .state ()
@@ -188,7 +191,6 @@ def test_constructor():
188
191
assert contract .getValue () == 2
189
192
190
193
191
- @pytest .mark .xfail (reason = 'bytecode in test seems to be wrong' )
192
194
@pytest .mark .skipif (not SOLIDITY_AVAILABLE , reason = 'solc compiler not available' )
193
195
def test_solidity_compile_rich ():
194
196
compile_rich_contract = """
@@ -211,22 +213,9 @@ def test_solidity_compile_rich():
211
213
'language' , 'languageVersion' , 'abiDefinition' , 'source' ,
212
214
'compilerVersion' , 'developerDoc' , 'userDoc'
213
215
}
214
- assert contract_info ['contract_add' ]['code' ] == (
215
- '0x606060405260ad8060116000396000f30060606040526000357c0100000000000000'
216
- '00000000000000000000000000000000000000000090048063651ae239146041578063'
217
- 'cb02919f14606657603f565b005b6050600480359060200150608b565b604051808281'
218
- '5260200191505060405180910390f35b6075600480359060200150609c565b60405180'
219
- '82815260200191505060405180910390f35b60006007820190506097565b919050565b'
220
- '6000602a8201905060a8565b91905056'
221
- )
222
- assert contract_info ['contract_sub' ]['code' ] == (
223
- '0x606060405260ad8060116000396000f30060606040526000357c0100000000000000'
224
- '0000000000000000000000000000000000000000009004806361752024146041578063'
225
- '7aaef1a014606657603f565b005b6050600480359060200150608b565b604051808281'
226
- '5260200191505060405180910390f35b6075600480359060200150609c565b60405180'
227
- '82815260200191505060405180910390f35b60006007820390506097565b919050565b'
228
- '6000602a8203905060a8565b91905056'
229
- )
216
+ assert bytecode_is_generated (contract_info , 'contract_add' )
217
+ assert bytecode_is_generated (contract_info , 'contract_sub' )
218
+
230
219
assert {
231
220
defn ['name' ]
232
221
for defn
@@ -285,10 +274,10 @@ def test_extra_args():
285
274
src ,
286
275
extra_args = "--optimize-runs 100"
287
276
)
288
- assert 'code' in contract_info [ 'foo' ]
277
+ assert bytecode_is_generated ( contract_info , 'foo' )
289
278
290
279
contract_info = get_solidity ().compile_rich (
291
280
src ,
292
281
extra_args = ["--optimize-runs" , "100" ]
293
282
)
294
- assert 'code' in contract_info [ 'foo' ]
283
+ assert bytecode_is_generated ( contract_info , 'foo' )
0 commit comments