forked from livepeer/go-livepeer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_args.sh
executable file
·195 lines (156 loc) · 6.48 KB
/
test_args.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/usr/bin/env bash
set -eux
# set a clean slate "home dir" for testing
TMPDIR=/tmp/livepeer-test-"$RANDOM"
DEFAULT_DATADIR="$TMPDIR"/.lpData
CUSTOM_DATADIR="$TMPDIR"/customDatadir
export HOME=$TMPDIR
rm -rf "$DEFAULT_DATADIR"
mkdir -p $TMPDIR # goclient should make the lpData datadir
# build the binary
HIGHEST_CHAIN_TAG=mainnet
go build -tags "$HIGHEST_CHAIN_TAG" -o $TMPDIR/livepeer cmd/livepeer/*.go
# Set up ethereum key
cat > $TMPDIR/key <<ETH_KEY
{"address":"089d8ab6752bac616a1f17246294eb068ee23d3e","crypto":{"cipher":"aes-128-ctr","ciphertext":"e868446e99842291b4991ae2c8e6c6834296c81937c4182e45af2edf0af61968","cipherparams":{"iv":"62205b25b7c4b2c35717128d9702f3c8"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"dfa46628fec666ebd46d21d59cd3cbad0039d13f3c09dd5304128e32edfdec57"},"mac":"a5d4cde1863803a2b17718eb6b0770c0e7fcdfcf3659c9bd24f033d4529a5af3"},"id":"b84a7400-5fbd-4397-894e-c59403663b88","version":3}
ETH_KEY
ETH_ARGS="-ethKeystorePath $TMPDIR/key"
SLEEP=0.25
run_lp () {
$TMPDIR/livepeer "$@" &
pid=$!
sleep $SLEEP
}
# sanity check that default datadir does not exist
[ ! -d "$DEFAULT_DATADIR" ]
# check that we exit early if node type is not set
res=0
$TMPDIR/livepeer || res=$?
[ $res -ne 0 ]
run_lp -broadcaster
[ -d "$DEFAULT_DATADIR"/offchain ]
kill $pid
run_lp -broadcaster -network rinkeby $ETH_ARGS
[ -d "$DEFAULT_DATADIR"/rinkeby ]
kill $pid
# Error if flags to set MaxBroadcastPrice aren't provided correctly
res=0
$TMPDIR/livepeer -broadcaster -network rinkeby $ETH_ARGS -maxPricePerUnit 0 -pixelsPerUnit -5 || res=$?
[ $res -ne 0 ]
run_lp -broadcaster -network mainnet $ETH_ARGS
[ -d "$DEFAULT_DATADIR"/mainnet ]
kill $pid
run_lp -broadcaster -network anyNetwork $ETH_ARGS -ethUrl "https://rinkeby.infura.io/v3/09642b98164d43eb890939eb9a7ec500" -v 99
[ -d "$DEFAULT_DATADIR"/anyNetwork ]
kill $pid
# sanity check that custom datadir does not exist
[ ! -d "$CUSTOM_DATADIR" ]
# check custom datadir without a network (offchain)
run_lp -broadcaster -datadir "$CUSTOM_DATADIR"
[ -d "$CUSTOM_DATADIR" ]
[ ! -d "$CUSTOM_DATADIR"/offchain ] # sanity check that network isn't included
kill $pid
CUSTOM_DATADIR="$TMPDIR"/customDatadir2
# sanity check that custom datadir does not exist
[ ! -d "$CUSTOM_DATADIR" ]
# check custom datadir with a network
run_lp -broadcaster -datadir "$CUSTOM_DATADIR" -network rinkeby $ETH_ARGS
[ ! -d "$CUSTOM_DATADIR"/rinkeby ] # sanity check that network isn't included
kill $pid
# check invalid service address via inserting control character
$TMPDIR/livepeer -orchestrator -orchSecret asdf -serviceAddr "hibye" 2>&1 | grep "Error getting service URI"
[ ${PIPESTATUS[0]} -ne 0 ]
# check missing service address via failed availability check
# Testing these isn't quite reliable enough (slow)
# XXX currently returns zero; should be nonzero
#$TMPDIR/livepeer -orchestrator -orchSecret asdf 2>&1 | grep "Orchestrator not available"
#$TMPDIR/livepeer -orchestrator -orchSecret asdf -serviceAddr livepeer.org 2>&1 | grep "Orchestrator not available"
# check that orchestrators require -orchSecret or -transcoder
# sanity check with -transcoder
run_lp -orchestrator -serviceAddr 127.0.0.1:8935 -transcoder
kill $pid
# sanity check with -orchSecret
run_lp -orchestrator -serviceAddr 127.0.0.1:8935 -orchSecret asdf
kill $pid
# XXX need a better way of confirming the error type. specialized exit code?
res=0
$TMPDIR/livepeer -orchestrator -serviceAddr 127.0.0.1:8935 || res=$?
[ $res -ne 0 ]
# Orchestrator needs to explicitly set PricePerUnit otherwise it will default to 0 resulting in a fatal error
res=0
$TMPDIR/livepeer -orchestrator -serviceAddr 127.0.0.1:8935 -transcoder -network rinkeby $ETH_ARGS || res=$?
[ $res -ne 0 ]
# Orchestrator needs PricePerUnit > 0
res=0
$TMPDIR/livepeer -orchestrator -serviceAddr 127.0.0.1:8935 -transcoder -pricePerUnit 0 -network rinkeby $ETH_ARGS || res=$?
[ $res -ne 0 ]
res=0
$TMPDIR/livepeer -orchestrator -serviceAddr 127.0.0.1:8935 -transcoder -pricePerUnit -5 -network rinkeby $ETH_ARGS || res=$?
[ $res -ne 0 ]
# Orchestrator needs PixelsPerUnit > 0
res=0
$TMPDIR/livepeer -orchestrator -serviceAddr 127.0.0.1:8935 -transcoder -pixelsPerUnit 0 -pricePerUnit 5 -network rinkeby $ETH_ARGS || res=$?
[ $res -ne 0 ]
res=0
$TMPDIR/livepeer -orchestrator -serviceAddr 127.0.0.1:8935 -transcoder -pixelsPerUnit -5 -pricePerUnit 5 -network rinkeby $ETH_ARGS || res=$?
[ $res -ne 0 ]
# Broadcaster needs a valid rational number for -maxTicketEV
res=0
$TMPDIR/livepeer -broadcaster -maxTicketEV abcd -network rinkeby $ETH_ARGS || res=$?
[ $res -ne 0 ]
# Broadcaster needs a non-negative number for -maxTicketEV
res=0
$TMPDIR/livepeer -broadcaster -maxTicketEV -1 -network rinkeby $ETH_ARGS || res=$?
[ $res -ne 0 ]
# Broadcaster needs a postive number for -depositMultiplier
res=0
$TMPDIR/livepeer -broadcaster -depositMultiplier 0 -network rinkeby $ETH_ARGS || res=$?
[ $res -ne 0 ]
# transcoder needs -orchSecret
res=0
$TMPDIR/livepeer -transcoder || res=$?
[ $res -ne 0 ]
# exit early if webhook url is not http
res=0
$TMPDIR/livepeer -broadcaster -authWebhookUrl tcp://host/ || res=$?
[ $res -ne 0 ]
# exit early if webhook url is not properly formatted
res=0
$TMPDIR/livepeer -broadcaster -authWebhookUrl http\\://host/ || res=$?
[ $res -ne 0 ]
# exit early if orchestrator webhook URL is not http
res=0
$TMPDIR/livepeer -broadcaster -orchWebhookUrl tcp://host/ || res=$?
[ $res -ne 0 ]
# exit early if orchestrator webhook URL is not properly formatted
res=0
$TMPDIR/livepeer -broadcaster -orchWebhookUrl http\\://host/ || res=$?
[ $res -ne 0 ]
# exit early if maxSessions less or equal to zero
res=0
$TMPDIR/livepeer -broadcaster -maxSessions -1 || res=$?
[ $res -ne 0 ]
res=0
$TMPDIR/livepeer -broadcaster -maxSessions 0 || res=$?
[ $res -ne 0 ]
# Check that pprof is running on CLI port
run_lp -broadcaster
curl -sI http://127.0.0.1:7935/debug/pprof/allocs | grep "200 OK"
kill $pid
# exit early if verifier URL is not http
res=0
$TMPDIR/livepeer -broadcaster -verifierUrl tcp://host/ || res=$?
[ $res -ne 0 ]
# exit early if verifier URL is not properly formatted
res=0
$TMPDIR/livepeer -broadcaster -verifierUrl http\\://host/ || res=$?
[ $res -ne 0 ]
# Check that verifier shared path is required
$TMPDIR/livepeer -broadcaster -verifierUrl http://host 2>&1 | grep "Requires a path to the"
# Check OK with verifier shared path
run_lp -broadcaster -verifierUrl http://host -verifierPath path
kill $pid
# Check OK with verifier + external storage
run_lp -broadcaster -verifierUrl http://host -s3bucket foo/bar -s3creds baz/bat
kill $pid
rm -rf $TMPDIR