-
Notifications
You must be signed in to change notification settings - Fork 24
/
test.sh
executable file
·141 lines (111 loc) · 2.46 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/env bash
# Exit if a command fails
set -o errexit
# Check commands
if ! command -v git &> /dev/null; then
echo "git command required"; exit
fi
if ! command -v npm &> /dev/null; then
echo "npm command required"; exit
fi
if ! command -v go &> /dev/null; then
echo "go command required"; exit
fi
##
# Config
##
# Rocket Pool settings
rp_repo_url="[email protected]:v3/rocket-pool/RocketPool/rocketpool"
rp_repo_branch="v1.1"
# Dependencies
rp_dependencies=(
"@openzeppelin/[email protected]"
"@truffle/hdwallet-provider@^1.2.3"
)
# Ganache settings
ganache_eth_balance="1000000"
ganache_gas_limit="12450000"
ganache_mnemonic="jungle neck govern chief unaware rubber frequent tissue service license alcohol velvet"
ganache_port="8545"
##
# Helpers
##
# Clean up
cleanup() {
# Remove RP repo
if [ -d "$rp_tmp_path" ]; then
rm -rf "$rp_tmp_path"
fi
# Kill ganache instance
if [ -n "$ganache_pid" ] && ps -p "$ganache_pid" > /dev/null; then
kill -9 "$ganache_pid"
fi
}
# Clone Rocket Pool repo
clone_rp() {
rp_tmp_path="$(mktemp -d)"
rp_path="$rp_tmp_path/rocketpool"
git clone "$rp_repo_url" -b "$rp_repo_branch" "$rp_path"
}
# Install Rocket Pool dependencies
install_rp_deps() {
cd "$rp_path"
rm package.json package-lock.json
npm install "${rp_dependencies[@]}"
cd - > /dev/null
}
# Start ganache-cli instance
start_ganache() {
cd "$rp_path"
node_modules/.bin/ganache-cli -e "$ganache_eth_balance" -l "$ganache_gas_limit" -m "$ganache_mnemonic" -p "$ganache_port" > /dev/null &
ganache_pid=$!
cd - > /dev/null
}
# Migrate Rocket Pool contracts
migrate_rp() {
cd "$rp_path"
node_modules/.bin/truffle migrate --network localhost
cd - > /dev/null
}
# Run tests
run_tests() {
go clean -testcache
go test -p 1 ./...
}
##
# Run
##
# Clean up before exiting
trap cleanup EXIT
# Clone RP repo
echo ""
echo "Cloning main Rocket Pool repository..."
echo ""
clone_rp
# Install RP deps
echo ""
echo "Installing Rocket Pool dependencies..."
echo ""
install_rp_deps
# Start ganache
echo ""
echo "Starting ganache-cli process..."
echo ""
start_ganache
# Migrate RP contracts
echo ""
echo "Migrating Rocket Pool contracts..."
echo ""
migrate_rp
# Run tests
echo ""
echo "Running tests..."
echo ""
run_tests