forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_basecli.sh
executable file
·69 lines (57 loc) · 1.85 KB
/
check_basecli.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
#!/bin/sh
# Note: Bucky, I know you want to kill bash tests.
# Please show me how to do an alternative to this.
# I would rather get code running before I leave than
# fight trying to invent some new test harness that
# no one else will understand.
#
# Thus, I leave this as an exercise to the reader to
# port into a non-bash version. And I don't do it proper...
# just automate my manual tests
# WARNING!!!
rm -rf ~/.basecoind ~/.basecli
cd $GOPATH/src/github.com/cosmos/cosmos-sdk
# make get_vendor_deps
make build
# init stuff
SEED=`./build/basecoind init | tail -1`
PASS='some-silly-123'
(echo $PASS; echo $SEED) | ./build/basecli keys add demo --recover
ADDR=`./build/basecli keys show demo | cut -f3`
echo "Recovered seed for demo:" $ADDR
# start up server
./build/basecoind start > ~/.basecoind/basecoind.log 2>&1 &
sleep 5
PID_SERVER=$!
# query original state
TO='ABCAFE00DEADBEEF00CAFE00DEADBEEF00CAFE00'
echo; echo "My account:" $ADDR
./build/basecli account $ADDR
echo; echo "Empty account:" $TO
./build/basecli account $TO
# send some money
TX=`echo $PASS | ./build/basecli send --to=$TO --amount=1000mycoin --from=demo --seq=0`
echo; echo "SendTx"; echo $TX
HASH=`echo $TX | cut -d' ' -f6`
echo "tx hash:" $HASH
# let some blocks come up....
./build/basecli status | jq .latest_block_height
sleep 2
./build/basecli status | jq .latest_block_height
# balances change
echo; echo "My account went down"
./build/basecli account $ADDR
echo; echo "Empty account got some cash"
./build/basecli account $TO
# query original tx
echo; echo "View tx"
./build/basecli tx $HASH
# wait a bit then dump out some blockchain state
sleep 10
./build/basecli status --trace
./build/basecli block --trace
./build/basecli validatorset --trace
# shutdown, but add a sleep if you want to manually run some cli scripts
# against this server before it goes away
# sleep 120
kill $PID_SERVER