Skip to content

Commit a439996

Browse files
authored
Merge pull request ethereum#14881 from ethereum/fix-detect-hardhat-artifacts
Fix `detect_hardhat_artifact_dir` in externalTests scripts
2 parents 602f855 + c8358f5 commit a439996

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

scripts/externalTests/common.sh

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -573,17 +573,15 @@ function gas_report_to_json
573573
cat - | "${REPO_ROOT}/scripts/externalTests/parse_eth_gas_report.py" | jq '{gas: .}'
574574
}
575575

576-
function detect_hardhat_artifact_dir
577-
{
578-
if [[ -e build/ && -e artifacts/ ]]; then
579-
fail "Cannot determine Hardhat artifact location. Both build/ and artifacts/ exist"
580-
elif [[ -e build/ ]]; then
581-
echo -n build/artifacts
582-
elif [[ -e artifacts/ ]]; then
583-
echo -n artifacts
584-
else
585-
fail "Hardhat build artifacts not found."
586-
fi
576+
function detect_hardhat_artifact_dirs
577+
{
578+
# NOTE: The artifacts path is a configured parameter in Hardhat, so the below may fail for new external tests
579+
# See: https://hardhat.org/hardhat-runner/docs/config#path-configuration
580+
local artifact_dir=()
581+
[[ -e build/artifacts ]] && artifact_dir+=("build/artifacts")
582+
[[ -e artifacts/ ]] && artifact_dir+=("artifacts")
583+
(( ${#artifact_dir[@]} != 0 )) || assertFail
584+
echo -n "${artifact_dir[@]}"
587585
}
588586

589587
function bytecode_size_json_from_truffle_artifacts
@@ -608,16 +606,17 @@ function bytecode_size_json_from_truffle_artifacts
608606
function bytecode_size_json_from_hardhat_artifacts
609607
{
610608
# NOTE: The output of this function is a series of concatenated JSON dicts rather than a list.
611-
612-
for artifact in "$(detect_hardhat_artifact_dir)"/build-info/*.json; do
613-
# Each artifact contains Standard JSON output under the `output` key.
614-
# Process it into a dict of the form `{"<file>": {"<contract>": <size>}}`,
615-
# Note that one Hardhat artifact often represents multiple input files.
616-
jq '.output.contracts | to_entries[] | {
617-
"\(.key)": .value | to_entries[] | {
618-
"\(.key)": (.value.evm.bytecode.object | length / 2)
619-
}
620-
}' "$artifact"
609+
for artifact_dir in $(detect_hardhat_artifact_dirs); do
610+
for artifact in "$artifact_dir"/build-info/*.json; do
611+
# Each artifact contains Standard JSON output under the `output` key.
612+
# Process it into a dict of the form `{"<file>": {"<contract>": <size>}}`,
613+
# Note that one Hardhat artifact often represents multiple input files.
614+
jq '.output.contracts | to_entries[] | {
615+
"\(.key)": .value | to_entries[] | {
616+
"\(.key)": (.value.evm.bytecode.object | length / 2)
617+
}
618+
}' "$artifact"
619+
done
621620
done
622621
}
623622

test/externalTests/ens.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function ens_test
8080
sed -i "s|it\(('Cannot be called if CANNOT_CREATE_SUBDOMAIN is burned and is a new subdomain',\)|it.skip\1|g" test/wrapper/NameWrapper.js
8181
sed -i "s|it\(('Cannot be called if PARENT_CANNOT_CONTROL is burned and is an existing subdomain',\)|it.skip\1|g" test/wrapper/NameWrapper.js
8282

83-
find . -name "*.sol" -exec sed -i -e 's/^\(\s*\)\(assembly\)/\1\/\/\/ @solidity memory-safe-assembly\n\1\2/' '{}' \;
83+
find . -name "*.sol" -type f -exec sed -i -e 's/^\(\s*\)\(assembly\)/\1\/\/\/ @solidity memory-safe-assembly\n\1\2/' '{}' \;
8484

8585
for preset in $SELECTED_PRESETS; do
8686
hardhat_run_test "$config_file" "$preset" "${compile_only_presets[*]}" compile_fn test_fn

0 commit comments

Comments
 (0)