scripts/ImportExportTest.sh: adding test for --optimized

This commit is contained in:
Alexander Arlt 2022-03-14 15:51:55 -05:00
parent 43faf23ed8
commit e8f76ff661

View File

@ -99,11 +99,13 @@ function testImportExportEquivalence {
UNCOMPILABLE=$((UNCOMPILABLE + 1))
return 0
else
$SOLC --optimize --combined-json bin,bin-runtime,opcodes,asm,srcmap,srcmap-runtime --pretty-json "$nth_input_file" "${all_input_files[@]}" > expected_optimized.json 2> expected_optimized.error
for contract in $(jq '.contracts | keys | .[]' expected.json 2> /dev/null)
do
for type in "${types[@]}"
do
jq --raw-output ".contracts.${contract}.\"${type}\"" expected.json > "expected.${type}"
jq --raw-output ".contracts.${contract}.\"${type}\"" expected_optimized.json > "expected_optimized.${type}"
done
assembly=$(cat expected.asm)
@ -117,27 +119,47 @@ function testImportExportEquivalence {
FAILED=$((FAILED + 1))
return 0
else
$SOLC --combined-json bin,bin-runtime,opcodes,asm,srcmap,srcmap-runtime --pretty-json --import-asm-json expected.asm > obtained_optimized.json 2> obtained_optimized.error
for type in "${types[@]}"
do
for obtained_contract in $(jq '.contracts | keys | .[]' obtained.json 2> /dev/null)
do
jq --raw-output ".contracts.${obtained_contract}.\"${type}\"" obtained.json > "obtained.${type}"
jq --raw-output ".contracts.${obtained_contract}.\"${type}\"" obtained_optimized.json > "obtained_optimized.${type}"
set +e
DIFF="$(diff "expected.${type}" "obtained.${type}")"
# DIFF_OPTIMIZED="$(diff "expected_optimized.${type}" "obtained_optimized.${type}")"
set -e
if [ "$DIFF" != "" ]
if [ "$DIFFVIEW" == "" ]
then
if [ "$DIFFVIEW" == "" ]
if [ "$DIFF" != "" ]
then
echo -e "ERROR: JSONS differ for $1: \n $DIFF \n"
echo "Expected:"
cat "expected.${type}"
echo "Obtained:"
cat "obtained.${type}"
else
# Use user supplied diff view binary
fi
if [ "$DIFF_OPTIMIZED" != "" ]
then
echo -e "ERROR: JSONS (optimized) differ for $1: \n $DIFF \n"
echo "Expected (optimized):"
cat "expected_optimized.${type}"
echo "Obtained (optimized):"
cat "obtained_optimized.${type}"
fi
else
# Use user supplied diff view binary
if [ "$DIFF" != "" ]
then
echo "$DIFFVIEW expected.json obtained.json"
$DIFFVIEW expected.json obtained.json
fi
if [ "$DIFF_OPTIMIZED" != "" ]
then
echo "$DIFFVIEW expected_optimized.json obtained_optimized.json"
$DIFFVIEW expected_optimized.json obtained_optimized.json
fi
_TESTED=
FAILED=$((FAILED + 1))
return 0