@@ -202,34 +202,29 @@ function test_evmjson_import_export_equivalence
202
202
local sol_file=" $1 "
203
203
local input_files=( " ${@: 2} " )
204
204
205
- # Compile files (generates the C.bin)
206
- mkdir -p sol /
207
- run_solc --bin " ${input_files[@]} " --output-dir sol/
208
- find sol/ -size 0 -delete
205
+ # Generate bytecode and EVM assembly JSON through normal complication
206
+ mkdir -p export /
207
+ local export_options=( --bin --asm-json " ${input_files[@]} " --output-dir export/)
208
+ run_solc " ${export_options[@]} "
209
209
210
- mkdir -p asm_json/
211
- local export_options=(--asm-json " ${input_files[@]} " --output-dir asm_json/)
210
+ # NOTE: If there is no bytecode, the compiler produces a JSON file that contains just 'null'.
211
+ # This is not accepted by assembly import though so we must skip such contracts.
212
+ echo -n null > null
213
+ find export/ -name ' *.json' -exec cmp --quiet --bytes=4 {} null \; -delete
212
214
213
- # Generate asm json file (generates C_evm.json)
214
- run_solc " ${export_options[@]} "
215
- for asm_json_file in asm_json /* .json
215
+ find export/ -name ' *.bin ' -size 0 -delete
216
+
217
+ for asm_json_file in export /* .json
216
218
do
217
- if [[ -n " $( jq --raw-output ' . // empty' " $asm_json_file " ) " ]]
218
- then
219
- # Remove '_evm' part of filename '<contract-name>_evm.json'
220
- mv " ${asm_json_file} " " ${asm_json_file/ _evm/ } "
221
- else
222
- # NOTE: If there is no bytecode, the compiler produces a JSON file that contains just 'null'.
223
- # This is not accepted by assembly import though so we must skip such contracts.
224
- rm " ${asm_json_file} "
225
- fi
219
+ mv " ${asm_json_file} " " ${asm_json_file/ _evm/ } "
226
220
done
227
221
228
- mkdir -p imported-from-sol/
229
- for asm_json_file in asm_json/* .json
222
+ # Import EVM assembly JSON
223
+ mkdir -p import/
224
+ for asm_json_file in export/* .json
230
225
do
231
226
local bin_file_from_asm_import
232
- bin_file_from_asm_import=" imported-from-sol /$( basename " ${asm_json_file} " .json) .bin"
227
+ bin_file_from_asm_import=" import /$( basename " ${asm_json_file} " .json) .bin"
233
228
234
229
local import_options=(--bin --import-asm-json " ${asm_json_file} " )
235
230
run_solc_store_stdout " ${bin_file_from_asm_import} " " ${import_options[@]} "
@@ -238,9 +233,10 @@ function test_evmjson_import_export_equivalence
238
233
mv tmpfile " $bin_file_from_asm_import "
239
234
done
240
235
241
- for bin_file in sol/*
236
+ # Compare bytecode from compilation with bytecode from import
237
+ for bin_file in export/* .bin
242
238
do
243
- local bin_file_from_asm_import=${bin_file/ sol / imported-from-sol }
239
+ local bin_file_from_asm_import=${bin_file/ export / import }
244
240
if ! diff --strip-trailing-cr --ignore-all-space " ${bin_file} " " ${bin_file_from_asm_import} " > diff_error
245
241
then
246
242
printError " ERROR: Bytecode from compilation (${bin_file} ) differs from bytecode from EVM asm import (${bin_file_from_asm_import} ):"
0 commit comments