-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathtest-zeth-cli
More file actions
executable file
·110 lines (88 loc) · 2.55 KB
/
Copy pathtest-zeth-cli
File metadata and controls
executable file
·110 lines (88 loc) · 2.55 KB
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
#!/usr/bin/env bash
set -e
set -x
if ! [ "$1" == "" ] ; then
echo == RUNNING ON NETWORK: $1 ==
eth_network=$1
else
eth_network=
fi
. scripts/test_zeth_cli_common.sh
BASE_DIR=_test_zeth_cli
DEPLOYER_DIR=${BASE_DIR}/deployer
ALICE_DIR=${BASE_DIR}/alice
BOB_DIR=${BASE_DIR}/bob
CHARLIE_DIR=${BASE_DIR}/charlie
# Setup addresses
mkdir -p ${BASE_DIR}
pushd ${BASE_DIR}
setup_user_local_key deployer ${eth_network}
setup_user_local_key alice ${eth_network}
setup_user_local_key bob ${eth_network}
setup_user_local_key charlie ${eth_network}
# Deploy
! [ -e deployer/zeth-instance ] && \
run_as deployer zeth deploy
copy_deployment_info deployer alice
copy_deployment_info deployer bob
copy_deployment_info deployer charlie
# Alice deposits 200 and sends 100 to Bob
pushd alice
# Test getting vk from prover server
[ -e vk.json ] || zeth get-verification-key --vk-out vk.json
alice_pk=`cat zeth-address.pub`
if ! [ -e notes/state_zeth ] ; then
# Uncomment the following command to create dispatch call data for this transaction
# zeth mix --wait --vin 200 --out ${alice_pk},200 \
# --for-dispatch-call \
# --dump-signing-keypair deposit_otsig_keypair.json \
# --dump-parameters deposit_mixparams.json
zeth mix --wait --vin 200 --out ${alice_pk},200
fi
note_id=`zeth ls-notes | tail -n 1 | grep -oe '^[A-Za-z0-9]\+'`
! [ "" == ${note_id} ]
bob_pk=`cat ../bob/zeth-address.pub`
zeth mix \
--wait \
--in ${note_id} \
--out 100 \
--out ../bob/zeth-address.pub,100
# Sync and check that our note has been spent
zeth sync
if (zeth ls-notes | grep ${note_id}) ; then
echo Expected note ${note_id} to be marked spent
exit 1
fi
popd # alice
# Bob scans the chain, finds his note, and sends 50 to Charlie
pushd bob
zeth sync
note_id=`zeth ls-notes | tail -n 1 | grep -oe '^[A-Za-z0-9]\+'`
! [ "" == ${note_id} ]
charlie_pk=`cat ../charlie/zeth-address.pub`
zeth mix \
--wait \
--in ${note_id} \
--out ${bob_pk},50 \
--out ${charlie_pk},50
popd # bob
echo BALANCES FOR WITHDRAW
show_balances
# Charlie scans the chain and withdraws his 50 ETH
pushd charlie
zeth sync
note_id=`zeth ls-notes | tail -n 1 | grep -oe '^[A-Za-z0-9]\+'`
! [ "" == ${note_id} ]
zeth mix \
--wait \
--in ${note_id} \
--vout 50
popd # charlie
echo BALANCES AFTER WITHDRAW
show_balances
popd # BASE_DIR
set +x
set +e
echo "============================================================"
echo "== PASSED =="
echo "============================================================"