-
Notifications
You must be signed in to change notification settings - Fork 47
/
e2e_tests.sh
executable file
·108 lines (86 loc) · 2.12 KB
/
e2e_tests.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
#!/bin/bash
# To run this script with a locally built loom binary set the LOOM_BIN env var to point to your loom
# binary. If you plan on running the tests frequently you'll save a lot of time if you run the
# steps in the setup_weave_blueprint in another directory, and then set LOOM_BLUEPRINT_DIR env var
# to point to it, otherwise the contract will be recloned and rebuilt every time.
set -euxo pipefail
ls $(go env GOPATH)
# Prepare env
DEFAULT_GOPATH=$(go env GOPATH)
GANACHE_PORT=8545
REPO_ROOT=`pwd`
LOOM_DIR=`pwd`/tmp/e2e
# Check available platforms
PLATFORM='unknown'
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
PLATFORM='linux'
elif [[ "$unamestr" == 'Darwin' ]]; then
PLATFORM='osx'
else
echo "Platform not supported on this script yet"
exit 1
fi
download_dappchain() {
cd $LOOM_DIR
wget -O loom https://downloads.loomx.io/loom/$PLATFORM/$BUILD_ID/loom-gateway
chmod +x loom
LOOM_BIN=`pwd`/loom
}
setup_weave_blueprint() {
cd $LOOM_DIR
git clone https://github.com/loomnetwork/weave-blueprint.git
cd weave-blueprint
LOOM_BLUEPRINT_DIR=`pwd`
make deps
make
}
setup_dappchain() {
cd $LOOM_DIR
$LOOM_BIN init -f
cp -R $REPO_ROOT/e2e_support/* .
cp -R $REPO_ROOT/e2e_support/tm-config/* chaindata/config/
# mkdir -p contracts
# cp $LOOM_BLUEPRINT_DIR/build/contracts/* contracts
}
start_chains() {
$REPO_ROOT/node_modules/.bin/ganache-cli -d -p $GANACHE_PORT >> ganache.log &
GANACHE_PID=$!
cd $LOOM_DIR
$LOOM_BIN run &
LOOM_PID=$!
sleep 5
$LOOM_BIN deploy -a public_key_acc_1 -k private_key_acc_1 -n SimpleStore -b ./SimpleStore.bin
}
stop_chains() {
if [[ -n "$GANACHE_PID" ]]; then
kill -9 $GANACHE_PID
GANACHE_PID=""
fi
if [[ -n "$LOOM_PID" ]]; then
kill -9 $LOOM_PID
LOOM_PID=""
fi
# pkill -f "${LOOM_DIR}/contracts/blueprint.0.0.1" || true
}
run_tests() {
yarn e2e:node
}
cleanup() {
stop_chains
export GOPATH=$DEFAULT_GOPATH
}
if [ "${CI:-}" ]; then
mkdir -p $LOOM_DIR
# setup_weave_blueprint
download_dappchain
fi
setup_dappchain
trap cleanup EXIT
start_chains
run_tests
cleanup
sleep 1
if [ "${CI:-}" ]; then
rm -rf $LOOM_DIR
fi