forked from aragon/aragon-id
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·69 lines (56 loc) · 2.34 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
# See https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/scripts/test.sh
# Exit script as soon as a command fails.
set -o errexit
# Executes cleanup function at script exit.
trap cleanup EXIT
cleanup() {
# Kill the testrpc instance that we started (if we started one and if it's still running).
if [ -n "$testrpc_pid" ] && ps -p $testrpc_pid > /dev/null; then
kill -9 $testrpc_pid
fi
}
if [ "$SOLIDITY_COVERAGE" = true ]; then
testrpc_port=8555
else
testrpc_port=8545
fi
testrpc_running() {
nc -z localhost "$testrpc_port"
}
start_testrpc() {
# We define 10 accounts with balance 1M ether, needed for high-value tests.
local accounts=(
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200,1000000000000000000000000"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501201,1000000000000000000000000"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501202,1000000000000000000000000"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501203,1000000000000000000000000"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501204,1000000000000000000000000"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501205,1000000000000000000000000"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501206,1000000000000000000000000"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501207,1000000000000000000000000"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501208,1000000000000000000000000"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501209,1000000000000000000000000"
)
if [ "$SOLIDITY_COVERAGE" = true ]; then
node_modules/.bin/testrpc-sc --gasLimit 0xfffffffffff --port "$testrpc_port" "${accounts[@]}" > /dev/null &
else
node_modules/.bin/testrpc --gasLimit 0xfffffffffff "${accounts[@]}" > /dev/null &
fi
testrpc_pid=$!
}
if testrpc_running; then
echo "Using existing testrpc instance"
else
echo "Starting our own testrpc instance"
start_testrpc
fi
if [ "$SOLIDITY_COVERAGE" = true ]; then
node_modules/.bin/solidity-coverage
result=$?
else
node_modules/.bin/truffle test --network testrpc "$@"
result=$?
fi
kill -9 $testrpc_pid
exit $result