@@ -361,6 +361,105 @@ def test_archive_b64_output(input_files):
361361 assert out [contract_file ] == out2 [archive_path ]
362362
363363
364+ def test_archive_compile_options (input_files ):
365+ tmpdir , _ , _ , contract_file = input_files
366+ search_paths = ["." , tmpdir ]
367+
368+ options = ["abi_python" , "json" , "ast" , "annotated_ast" , "ir_json" ]
369+
370+ for option in options :
371+ out = compile_files ([contract_file ], ["archive_b64" , option ], paths = search_paths )
372+
373+ archive_b64 = out [contract_file ].pop ("archive_b64" )
374+
375+ archive_path = Path ("foo.zip.b64" )
376+ with archive_path .open ("w" ) as f :
377+ f .write (archive_b64 )
378+
379+ # compare compiling the two input bundles
380+ out2 = compile_files ([archive_path ], [option ])
381+
382+ if option in ["ast" , "annotated_ast" ]:
383+ # would have to normalize paths and imports, so just verify it compiles
384+ continue
385+
386+ assert out [contract_file ] == out2 [archive_path ]
387+
388+
389+ format_options = [
390+ "bytecode" ,
391+ "bytecode_runtime" ,
392+ "blueprint_bytecode" ,
393+ "abi" ,
394+ "abi_python" ,
395+ "source_map" ,
396+ "source_map_runtime" ,
397+ "method_identifiers" ,
398+ "userdoc" ,
399+ "devdoc" ,
400+ "metadata" ,
401+ "combined_json" ,
402+ "layout" ,
403+ "ast" ,
404+ "annotated_ast" ,
405+ "interface" ,
406+ "external_interface" ,
407+ "opcodes" ,
408+ "opcodes_runtime" ,
409+ "ir" ,
410+ "ir_json" ,
411+ "ir_runtime" ,
412+ "asm" ,
413+ "integrity" ,
414+ "archive" ,
415+ "solc_json" ,
416+ ]
417+
418+
419+ def test_compile_vyz_with_options (input_files ):
420+ tmpdir , _ , _ , contract_file = input_files
421+ search_paths = ["." , tmpdir ]
422+
423+ for option in format_options :
424+ out_archive = compile_files ([contract_file ], ["archive" ], paths = search_paths )
425+
426+ archive = out_archive [contract_file ].pop ("archive" )
427+
428+ archive_path = Path ("foo.zip.out.vyz" )
429+ with archive_path .open ("wb" ) as f :
430+ f .write (archive )
431+
432+ # compare compiling the two input bundles
433+ out = compile_files ([contract_file ], [option ], paths = search_paths )
434+ out2 = compile_files ([archive_path ], [option ])
435+
436+ if option in ["ast" , "annotated_ast" , "metadata" ]:
437+ # would have to normalize paths and imports, so just verify it compiles
438+ continue
439+
440+ if option in ["ir_runtime" , "ir" , "archive" ]:
441+ # ir+ir_runtime is different due to being different compiler runs
442+ # archive is different due to different metadata (timestamps)
443+ continue
444+
445+ assert out [contract_file ] == out2 [archive_path ]
446+
447+
448+ def test_archive_compile_simultaneous_options (input_files ):
449+ tmpdir , _ , _ , contract_file = input_files
450+ search_paths = ["." , tmpdir ]
451+
452+ for option in format_options :
453+ with pytest .raises (ValueError ) as e :
454+ _ = compile_files ([contract_file ], ["archive" , option ], paths = search_paths )
455+
456+ err_opt = "archive"
457+ if option in ("combined_json" , "solc_json" ):
458+ err_opt = option
459+
460+ assert f"If using { err_opt } it must be the only output format requested" in str (e .value )
461+
462+
364463def test_solc_json_output (input_files ):
365464 tmpdir , _ , _ , contract_file = input_files
366465 search_paths = ["." , tmpdir ]
0 commit comments