65 lines
1.4 KiB
Bash
Executable File
65 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Exit script as soon as a command fails.
|
|
set -o errexit
|
|
|
|
# Executes cleanup function at script exit.
|
|
trap cleanup EXIT
|
|
|
|
cleanup() {
|
|
# Kill the RPC instance that we started (if we started one and if it's still running).
|
|
if [ -n "$rpc_pid" ] && ps -p $rpc_pid > /dev/null; then
|
|
kill -9 $rpc_pid
|
|
fi
|
|
}
|
|
|
|
setup_coverage_variables() {
|
|
PORT=${PORT-8555}
|
|
BALANCE=${BALANCE-100000}
|
|
GAS_LIMIT=${GAS_LIMIT-0xfffffffffff}
|
|
NETWORK_ID=${NETWORK_ID-16}
|
|
}
|
|
|
|
setup_testing_variables() {
|
|
PORT=${PORT-8545}
|
|
BALANCE=${BALANCE-100000}
|
|
GAS_LIMIT=${GAS_LIMIT-8000000}
|
|
NETWORK_ID=${NETWORK_ID-15}
|
|
}
|
|
|
|
start_ganache() {
|
|
echo "Starting ganache-cli..."
|
|
npx ganache-cli -i ${NETWORK_ID} -l ${GAS_LIMIT} -e ${BALANCE} -p ${PORT} > /dev/null &
|
|
rpc_pid=$!
|
|
sleep 3
|
|
echo "Running ganache-cli with pid ${rpc_pid} in port ${PORT}"
|
|
}
|
|
|
|
start_testrpc() {
|
|
echo "Starting testrpc-sc..."
|
|
npx testrpc-sc -i ${NETWORK_ID} -l ${GAS_LIMIT} -e ${BALANCE} -p ${PORT} > /dev/null &
|
|
rpc_pid=$!
|
|
sleep 3
|
|
echo "Running testrpc-sc with pid ${rpc_pid} in port ${PORT}"
|
|
}
|
|
|
|
measure_coverage() {
|
|
echo "Measuring coverage..."
|
|
npx solidity-coverage "$@"
|
|
}
|
|
|
|
run_tests() {
|
|
echo "Running tests..."
|
|
npx aragon contracts test --network rpc "$@"
|
|
}
|
|
|
|
if [ "$SOLIDITY_COVERAGE" = true ]; then
|
|
setup_coverage_variables
|
|
start_testrpc
|
|
measure_coverage
|
|
else
|
|
setup_testing_variables
|
|
start_ganache
|
|
run_tests
|
|
fi
|