1
1
#! /usr/bin/env bash
2
2
3
3
# Bash script to test the asm-json-import input mode of the compiler by
4
- # first exporting a .sol file to JSON that containing assembly json and corresponding bytecode,
4
+ # first exporting a .sol file to JSON that containing assembly json, deploy & runtime bytecode, opcodes and source mappings ,
5
5
# then the compiler is invoked in assembly json import mode `--import-asm-json` and uses the previously
6
- # generated assembly json as input, where the corresponding bytecode output will be stored.
7
- # Finally, the originally generated bytecode will be compared with the one that was generated by using the
8
- # assembly json file as input.
6
+ # generated assembly. This output will be stored.
7
+ # Finally, the originally generated outputs (bin, bin-runtime, opcodes, asm, srcmap and srcmap-runtime)
8
+ # will be compared with the outputs that where generated by using the assembly json file as input.
9
9
10
10
set -eo pipefail
11
11
READLINK=readlink
@@ -34,7 +34,6 @@ function testImportExportEquivalence {
34
34
if $SOLC " $nth_input_file " " ${all_input_files[@]} " --combined-json asm,bin > /dev/null 2>&1
35
35
then
36
36
local types=( " bin" " bin-runtime" " opcodes" " asm" " srcmap" " srcmap-runtime" )
37
- local test_types=( " bin" " bin-runtime" " opcodes" " asm" )
38
37
39
38
# save exported json as expected result (silently)
40
39
$SOLC --combined-json asm,opcodes,bin,srcmap,srcmap-runtime,bin-runtime --pretty-json " $nth_input_file " " ${all_input_files[@]} " > expected.json 2> /dev/null
@@ -62,7 +61,7 @@ function testImportExportEquivalence {
62
61
return 1
63
62
fi
64
63
65
- for type in " ${test_types [@]} "
64
+ for type in " ${types [@]} "
66
65
do
67
66
jq --raw-output " .contracts.\" expected.asm\" .\" ${type} \" " imported.json > " imported.${type} "
68
67
if ! diff " expected.${type} " " imported.${type} "
@@ -77,7 +76,7 @@ function testImportExportEquivalence {
77
76
echo " Obtained:"
78
77
cat " ./imported.${type} "
79
78
else
80
- # Use user supplied diff view binary
79
+ # Use user supplied diff view mismatched output
81
80
$DIFFVIEW " expected.${type} " " imported.${type} "
82
81
fi
83
82
FAILED=$(( FAILED + 1 ))
@@ -86,12 +85,17 @@ function testImportExportEquivalence {
86
85
done
87
86
done
88
87
TESTED=$(( TESTED + 1 ))
89
- rm -f expected.json asm.json expected.bin imported.bin
88
+ rm -f expected.json
89
+ rm -f imported.json
90
+ for type in " ${types[@]} "
91
+ do
92
+ rm -f " expected.${type} "
93
+ rm -f " imported.${type} "
94
+ done
90
95
else
91
96
# echo "contract $solfile could not be compiled "
92
97
UNCOMPILABLE=$(( UNCOMPILABLE + 1 ))
93
98
fi
94
- # return 0
95
99
}
96
100
echo " Looking at $NSOURCES .sol files..."
97
101
0 commit comments