forked from livepeer/go-livepeer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_args.sh
executable file
·97 lines (75 loc) · 3.09 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
#!/usr/bin/env bash
set -eux
# build the binary
go build cmd/livepeer/livepeer.go
# 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
# 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 () {
./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
./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
run_lp -broadcaster -network mainnet $ETH_ARGS
[ -d "$DEFAULT_DATADIR"/mainnet ]
kill $pid
run_lp -broadcaster -network anyNetwork $ETH_ARGS -ethUrl "wss://rinkeby.infura.io/ws" -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
# 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
./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
#./livepeer -orchestrator -orchSecret asdf 2>&1 | grep "Orchestrator not available"
#./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
./livepeer -orchestrator -serviceAddr 127.0.0.1:8935 || res=$?
[ $res -ne 0 ]
# transcoder needs -orchSecret
res=0
./livepeer -transcoder || res=$?
[ $res -ne 0 ]
rm -rf "$TMPDIR"