Skip to content

Commit

Permalink
Generalize force_truffle_solc_modules and make it use symlinks instea…
Browse files Browse the repository at this point in the history
…d of redownloading solc-js
  • Loading branch information
cameel committed Oct 27, 2021
1 parent 08f97b1 commit 7631448
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion test/externalTests/colony.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function colony_test
cd ..

replace_version_pragmas
force_truffle_solc_modules "$SOLJSON"
force_solc_modules "${DIR}/solc"

for level in $(seq "$min_optimizer_level" "$max_optimizer_level"); do
truffle_run_test "$config_file" "${DIR}/solc" "$level" compile_fn test_fn
Expand Down
29 changes: 13 additions & 16 deletions test/externalTests/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,25 +110,22 @@ function neutralize_package_json_hooks
sed -i 's|"prepare": *".*"|"prepare": ""|g' package.json
}

function force_truffle_solc_modules
function force_solc_modules
{
local soljson="$1"
local custom_solcjs_path="${1:-solc/}"

[[ -d node_modules/ ]] || assertFail

# Replace solc package by v0.5.0 and then overwrite with current version.
printLog "Forcing solc version for all Truffle modules..."
for d in node_modules node_modules/truffle/node_modules
printLog "Replacing all installed solc-js with a link to the latest version..."
soljson_binaries=$(find node_modules -type f -path "*/solc/soljson.js")
for soljson_binary in $soljson_binaries
do
(
if [ -d "$d" ]; then
cd $d
rm -rf solc
git clone --depth 1 -b master https://github.com/ethereum/solc-js.git solc
cp "$soljson" solc/soljson.js

cd solc
npm install
fi
)
local solc_module_path
solc_module_path=$(dirname "$soljson_binary")

printLog "Found and replaced solc-js in $solc_module_path"
rm -r "$solc_module_path"
ln -s "$custom_solcjs_path" "$solc_module_path"
done
}

Expand Down
2 changes: 1 addition & 1 deletion test/externalTests/ens.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function ens_test
npm install

replace_version_pragmas
force_truffle_solc_modules "$SOLJSON"
force_solc_modules "${DIR}/solc"

for level in $(seq "$min_optimizer_level" "$max_optimizer_level"); do
truffle_run_test "$config_file" "${DIR}/solc" "$level" compile_fn test_fn
Expand Down
2 changes: 1 addition & 1 deletion test/externalTests/gnosis-v2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function gnosis_safe_test
npm install --package-lock

replace_version_pragmas
force_truffle_solc_modules "$SOLJSON"
force_solc_modules "${DIR}/solc"

for level in $(seq "$min_optimizer_level" "$max_optimizer_level"); do
truffle_run_test "$config_file" "${DIR}/solc" "$level" compile_fn test_fn
Expand Down
2 changes: 1 addition & 1 deletion test/externalTests/gnosis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function gnosis_safe_test
npm install --package-lock

replace_version_pragmas
force_truffle_solc_modules "$SOLJSON"
force_solc_modules "${DIR}/solc"

for level in $(seq "$min_optimizer_level" "$max_optimizer_level"); do
truffle_run_test "$config_file" "${DIR}/solc" "$level" compile_fn test_fn
Expand Down
2 changes: 1 addition & 1 deletion test/externalTests/zeppelin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function zeppelin_test
npm install

replace_version_pragmas
force_truffle_solc_modules "$SOLJSON"
force_solc_modules "${DIR}/solc"

for level in $(seq "$min_optimizer_level" "$max_optimizer_level"); do
truffle_run_test "$config_file" "${DIR}/solc" "$level" compile_fn test_fn
Expand Down

0 comments on commit 7631448

Please sign in to comment.