mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
externalTests: Refactor setup and input verification
This commit is contained in:
parent
0edbd90f52
commit
081b80ccb2
@ -28,25 +28,20 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ ! -f "$1" ]
|
|
||||||
then
|
|
||||||
echo "Usage: $0 <path to soljson.js>"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
SOLJSON="$1"
|
|
||||||
REPO_ROOT="$(dirname "$0")"
|
REPO_ROOT="$(dirname "$0")"
|
||||||
|
|
||||||
source scripts/common.sh
|
source scripts/common.sh
|
||||||
source test/externalTests/common.sh
|
source test/externalTests/common.sh
|
||||||
|
|
||||||
|
verify_input "$@"
|
||||||
|
|
||||||
printTask "Running external tests..."
|
printTask "Running external tests..."
|
||||||
|
|
||||||
"$REPO_ROOT/externalTests/zeppelin.sh" "$SOLJSON"
|
"$REPO_ROOT/externalTests/zeppelin.sh" "$@"
|
||||||
"$REPO_ROOT/externalTests/gnosis.sh" "$SOLJSON"
|
"$REPO_ROOT/externalTests/gnosis.sh" "$@"
|
||||||
"$REPO_ROOT/externalTests/gnosis-v2.sh" "$SOLJSON"
|
"$REPO_ROOT/externalTests/gnosis-v2.sh" "$@"
|
||||||
"$REPO_ROOT/externalTests/colony.sh" "$SOLJSON"
|
"$REPO_ROOT/externalTests/colony.sh" "$@"
|
||||||
"$REPO_ROOT/externalTests/ens.sh" "$SOLJSON"
|
"$REPO_ROOT/externalTests/ens.sh" "$@"
|
||||||
|
|
||||||
# Disabled temporarily as it needs to be updated to latest Truffle first.
|
# Disabled temporarily as it needs to be updated to latest Truffle first.
|
||||||
#test_truffle Gnosis https://github.com/axic/pm-contracts.git solidity-050
|
#test_truffle Gnosis https://github.com/axic/pm-contracts.git solidity-050
|
||||||
|
@ -24,8 +24,8 @@ set -e
|
|||||||
source scripts/common.sh
|
source scripts/common.sh
|
||||||
source test/externalTests/common.sh
|
source test/externalTests/common.sh
|
||||||
|
|
||||||
verify_input "$1"
|
verify_input "$@"
|
||||||
SOLJSON="$1"
|
BINARY_PATH="$1"
|
||||||
|
|
||||||
function compile_fn { yarn run provision:token:contracts; }
|
function compile_fn { yarn run provision:token:contracts; }
|
||||||
function test_fn { yarn run test:contracts; }
|
function test_fn { yarn run test:contracts; }
|
||||||
@ -42,7 +42,7 @@ function colony_test
|
|||||||
selected_optimizer_levels=$(circleci_select_steps "$(seq "$min_optimizer_level" "$max_optimizer_level")")
|
selected_optimizer_levels=$(circleci_select_steps "$(seq "$min_optimizer_level" "$max_optimizer_level")")
|
||||||
print_optimizer_levels_or_exit "$selected_optimizer_levels"
|
print_optimizer_levels_or_exit "$selected_optimizer_levels"
|
||||||
|
|
||||||
setup_solcjs "$DIR" "$SOLJSON"
|
setup_solcjs "$DIR" "$BINARY_PATH"
|
||||||
download_project "$repo" "$branch" "$DIR"
|
download_project "$repo" "$branch" "$DIR"
|
||||||
|
|
||||||
neutralize_package_json_hooks
|
neutralize_package_json_hooks
|
||||||
|
@ -35,52 +35,41 @@ function print_optimizer_levels_or_exit
|
|||||||
|
|
||||||
function verify_input
|
function verify_input
|
||||||
{
|
{
|
||||||
[[ -f "$1" ]] || fail "Usage: $0 <path to soljson.js>"
|
local binary_path="$1"
|
||||||
|
|
||||||
|
(( $# == 1 )) || fail "Usage: $0 <path to soljson.js>"
|
||||||
|
[[ -f "$binary_path" ]] || fail "The compiler binary does not exist at '${binary_path}'"
|
||||||
}
|
}
|
||||||
|
|
||||||
function verify_version_input
|
|
||||||
{
|
|
||||||
[[ $1 != "" && -f "$1" && $2 != "" ]] || fail "Usage: $0 <path to soljson.js> <version>"
|
|
||||||
}
|
|
||||||
|
|
||||||
function setup
|
|
||||||
{
|
|
||||||
local soljson="$1"
|
|
||||||
local branch="$2"
|
|
||||||
|
|
||||||
setup_solcjs "$DIR" "$soljson" "$branch" "solc"
|
|
||||||
cd solc
|
|
||||||
}
|
|
||||||
|
|
||||||
function setup_solcjs
|
function setup_solcjs
|
||||||
{
|
{
|
||||||
local dir="$1"
|
local test_dir="$1"
|
||||||
local soljson="$2"
|
local binary_path="$2"
|
||||||
local branch="${3:-master}"
|
local solcjs_branch="${3:-master}"
|
||||||
local path="${4:-solc/}"
|
local install_dir="${4:-solc/}"
|
||||||
|
|
||||||
cd "$dir"
|
cd "$test_dir"
|
||||||
printLog "Setting up solc-js..."
|
printLog "Setting up solc-js..."
|
||||||
git clone --depth 1 -b "$branch" https://github.com/ethereum/solc-js.git "$path"
|
git clone --depth 1 -b "$solcjs_branch" https://github.com/ethereum/solc-js.git "$install_dir"
|
||||||
|
|
||||||
cd "$path"
|
|
||||||
|
|
||||||
|
pushd "$install_dir"
|
||||||
npm install
|
npm install
|
||||||
cp "$soljson" soljson.js
|
cp "$binary_path" soljson.js
|
||||||
SOLCVERSION=$(./solcjs --version)
|
SOLCVERSION=$(./solcjs --version)
|
||||||
SOLCVERSION_SHORT=$(echo "$SOLCVERSION" | sed -En 's/^([0-9.]+).*\+commit\.[0-9a-f]+.*$/\1/p')
|
SOLCVERSION_SHORT=$(echo "$SOLCVERSION" | sed -En 's/^([0-9.]+).*\+commit\.[0-9a-f]+.*$/\1/p')
|
||||||
printLog "Using solcjs version $SOLCVERSION"
|
printLog "Using compiler version $SOLCVERSION"
|
||||||
cd ..
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
function download_project
|
function download_project
|
||||||
{
|
{
|
||||||
local repo="$1"
|
local repo="$1"
|
||||||
local branch="$2"
|
local solcjs_branch="$2"
|
||||||
local dir="$3"
|
local test_dir="$3"
|
||||||
|
|
||||||
printLog "Cloning $branch of $repo..."
|
printLog "Cloning $solcjs_branch of $repo..."
|
||||||
git clone --depth 1 "$repo" -b "$branch" "$dir/ext"
|
git clone --depth 1 "$repo" -b "$solcjs_branch" "$test_dir/ext"
|
||||||
cd ext
|
cd ext
|
||||||
echo "Current commit hash: $(git rev-parse HEAD)"
|
echo "Current commit hash: $(git rev-parse HEAD)"
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,8 @@ set -e
|
|||||||
source scripts/common.sh
|
source scripts/common.sh
|
||||||
source test/externalTests/common.sh
|
source test/externalTests/common.sh
|
||||||
|
|
||||||
verify_input "$1"
|
verify_input "$@"
|
||||||
export SOLJSON="$1"
|
BINARY_PATH="$1"
|
||||||
|
|
||||||
function compile_fn { npx truffle compile; }
|
function compile_fn { npx truffle compile; }
|
||||||
function test_fn { npm run test; }
|
function test_fn { npm run test; }
|
||||||
@ -42,7 +42,7 @@ function ens_test
|
|||||||
selected_optimizer_levels=$(circleci_select_steps "$(seq "$min_optimizer_level" "$max_optimizer_level")")
|
selected_optimizer_levels=$(circleci_select_steps "$(seq "$min_optimizer_level" "$max_optimizer_level")")
|
||||||
print_optimizer_levels_or_exit "$selected_optimizer_levels"
|
print_optimizer_levels_or_exit "$selected_optimizer_levels"
|
||||||
|
|
||||||
setup_solcjs "$DIR" "$SOLJSON"
|
setup_solcjs "$DIR" "$BINARY_PATH"
|
||||||
download_project "$repo" "$branch" "$DIR"
|
download_project "$repo" "$branch" "$DIR"
|
||||||
|
|
||||||
# Use latest Truffle. Older versions crash on the output from 0.8.0.
|
# Use latest Truffle. Older versions crash on the output from 0.8.0.
|
||||||
|
@ -24,10 +24,9 @@ set -e
|
|||||||
source scripts/common.sh
|
source scripts/common.sh
|
||||||
source test/externalTests/common.sh
|
source test/externalTests/common.sh
|
||||||
|
|
||||||
verify_input "$1"
|
verify_input "$@"
|
||||||
SOLJSON="$1"
|
BINARY_PATH="$1"
|
||||||
|
|
||||||
function install_fn { npm install --package-lock; }
|
|
||||||
function compile_fn { npx truffle compile; }
|
function compile_fn { npx truffle compile; }
|
||||||
function test_fn { npm test; }
|
function test_fn { npm test; }
|
||||||
|
|
||||||
@ -43,7 +42,7 @@ function gnosis_safe_test
|
|||||||
selected_optimizer_levels=$(circleci_select_steps "$(seq "$min_optimizer_level" "$max_optimizer_level")")
|
selected_optimizer_levels=$(circleci_select_steps "$(seq "$min_optimizer_level" "$max_optimizer_level")")
|
||||||
print_optimizer_levels_or_exit "$selected_optimizer_levels"
|
print_optimizer_levels_or_exit "$selected_optimizer_levels"
|
||||||
|
|
||||||
setup_solcjs "$DIR" "$SOLJSON"
|
setup_solcjs "$DIR" "$BINARY_PATH"
|
||||||
download_project "$repo" "$branch" "$DIR"
|
download_project "$repo" "$branch" "$DIR"
|
||||||
|
|
||||||
sed -i 's|github:gnosis/mock-contract#sol_0_5_0|github:solidity-external-tests/mock-contract#master_080|g' package.json
|
sed -i 's|github:gnosis/mock-contract#sol_0_5_0|github:solidity-external-tests/mock-contract#master_080|g' package.json
|
||||||
|
@ -24,8 +24,8 @@ set -e
|
|||||||
source scripts/common.sh
|
source scripts/common.sh
|
||||||
source test/externalTests/common.sh
|
source test/externalTests/common.sh
|
||||||
|
|
||||||
verify_input "$1"
|
verify_input "$@"
|
||||||
SOLJSON="$1"
|
BINARY_PATH="$1"
|
||||||
|
|
||||||
function compile_fn { npx truffle compile; }
|
function compile_fn { npx truffle compile; }
|
||||||
function test_fn { npm test; }
|
function test_fn { npm test; }
|
||||||
@ -42,7 +42,7 @@ function gnosis_safe_test
|
|||||||
selected_optimizer_levels=$(circleci_select_steps "$(seq "$min_optimizer_level" "$max_optimizer_level")")
|
selected_optimizer_levels=$(circleci_select_steps "$(seq "$min_optimizer_level" "$max_optimizer_level")")
|
||||||
print_optimizer_levels_or_exit "$selected_optimizer_levels"
|
print_optimizer_levels_or_exit "$selected_optimizer_levels"
|
||||||
|
|
||||||
setup_solcjs "$DIR" "$SOLJSON"
|
setup_solcjs "$DIR" "$BINARY_PATH"
|
||||||
download_project "$repo" "$branch" "$DIR"
|
download_project "$repo" "$branch" "$DIR"
|
||||||
|
|
||||||
sed -i 's|github:gnosis/mock-contract#sol_0_5_0|github:solidity-external-tests/mock-contract#master_080|g' package.json
|
sed -i 's|github:gnosis/mock-contract#sol_0_5_0|github:solidity-external-tests/mock-contract#master_080|g' package.json
|
||||||
|
@ -24,10 +24,11 @@ set -e
|
|||||||
source scripts/common.sh
|
source scripts/common.sh
|
||||||
source test/externalTests/common.sh
|
source test/externalTests/common.sh
|
||||||
|
|
||||||
verify_version_input "$1" "$2"
|
|
||||||
SOLJSON="$1"
|
SOLJSON="$1"
|
||||||
VERSION="$2"
|
VERSION="$2"
|
||||||
|
|
||||||
|
[[ $SOLJSON != "" && -f "$SOLJSON" && $VERSION != "" ]] || fail "Usage: $0 <path to soljson.js> <version>"
|
||||||
|
|
||||||
function compile_fn { echo "Nothing to compile."; }
|
function compile_fn { echo "Nothing to compile."; }
|
||||||
function test_fn { npm test; }
|
function test_fn { npm test; }
|
||||||
|
|
||||||
@ -37,7 +38,8 @@ function solcjs_test
|
|||||||
SOLCJS_INPUT_DIR="$TEST_DIR"/test/externalTests/solc-js
|
SOLCJS_INPUT_DIR="$TEST_DIR"/test/externalTests/solc-js
|
||||||
|
|
||||||
# set up solc-js on the branch specified
|
# set up solc-js on the branch specified
|
||||||
setup "$SOLJSON" master
|
setup_solcjs "$DIR" "$SOLJSON" master solc/
|
||||||
|
cd solc/
|
||||||
|
|
||||||
printLog "Updating index.js file..."
|
printLog "Updating index.js file..."
|
||||||
echo "require('./determinism.js');" >> test/index.js
|
echo "require('./determinism.js');" >> test/index.js
|
||||||
|
@ -24,8 +24,8 @@ set -e
|
|||||||
source scripts/common.sh
|
source scripts/common.sh
|
||||||
source test/externalTests/common.sh
|
source test/externalTests/common.sh
|
||||||
|
|
||||||
verify_input "$1"
|
verify_input "$@"
|
||||||
SOLJSON="$1"
|
BINARY_PATH="$1"
|
||||||
|
|
||||||
function compile_fn { npm run compile; }
|
function compile_fn { npm run compile; }
|
||||||
function test_fn { npm test; }
|
function test_fn { npm test; }
|
||||||
@ -42,11 +42,11 @@ function zeppelin_test
|
|||||||
selected_optimizer_levels=$(circleci_select_steps "$(seq "$min_optimizer_level" "$max_optimizer_level")")
|
selected_optimizer_levels=$(circleci_select_steps "$(seq "$min_optimizer_level" "$max_optimizer_level")")
|
||||||
print_optimizer_levels_or_exit "$selected_optimizer_levels"
|
print_optimizer_levels_or_exit "$selected_optimizer_levels"
|
||||||
|
|
||||||
setup_solcjs "$DIR" "$SOLJSON"
|
setup_solcjs "$DIR" "$BINARY_PATH"
|
||||||
download_project "$repo" "$branch" "$DIR"
|
download_project "$repo" "$branch" "$DIR"
|
||||||
|
|
||||||
neutralize_package_json_hooks
|
neutralize_package_json_hooks
|
||||||
force_hardhat_compiler_binary "$config_file" "$SOLJSON"
|
force_hardhat_compiler_binary "$config_file" "$BINARY_PATH"
|
||||||
force_hardhat_compiler_settings "$config_file" "$min_optimizer_level"
|
force_hardhat_compiler_settings "$config_file" "$min_optimizer_level"
|
||||||
npm install
|
npm install
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user