20
20
21
21
function init() {
22
22
# update test environment
23
+ sed -i $sedfix ' s/^Title.*/Title="local"/g' chain33.toml
23
24
sed -i $sedfix ' s/^TestNet=.*/TestNet=true/g' chain33.toml
24
25
25
26
# p2p
@@ -136,21 +137,39 @@ function init() {
136
137
# ${CLI} mempool last_txs
137
138
}
138
139
140
+ function block_wait() {
141
+ if [ " $# " -lt 2 ]; then
142
+ echo " wrong block_wait params"
143
+ exit 1
144
+ fi
145
+ cur_height=$( ${1} block last_header | jq " .height" )
146
+ expect=$(( cur_height + ${2} ))
147
+ count=0
148
+ while true ; do
149
+ new_height=$( ${1} block last_header | jq " .height" )
150
+ if [ " ${new_height} " -ge " ${expect} " ]; then
151
+ break
152
+ fi
153
+ count=$(( count + 1 ))
154
+ sleep 1
155
+ done
156
+ echo " wait new block $count s"
157
+ }
158
+
139
159
function transfer() {
140
160
echo " =========== # transfer ============="
141
161
hashes=()
142
162
for (( i = 0 ; i < 10 ; i++ )) ; do
143
163
hash=$( ${CLI} send bty transfer -a 1 -n test -t 14KEKbYtKKQm4wMthSK9J4La4nAiidGozt -k 4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01)
144
- hashes=(" ${hashes[*]} " " $hash " )
145
- sleep 1
164
+ hashes=(" ${hashes[@]} " " $hash " )
146
165
done
166
+ block_wait " ${CLI} " 1
147
167
echo " len: ${# hashes[@]} "
148
- if [ ${# hashes[*]} != 10 ]; then
149
- echo tx number wrong
168
+ if [ " ${# hashes[@]} " != 10 ]; then
169
+ echo " tx number wrong"
150
170
exit 1
151
171
fi
152
172
153
- sleep 20
154
173
for (( i = 0 ; i < ${# hashes[*]} ; i++ )) ; do
155
174
txs=$( ${CLI} tx query_hash -s " ${hashes[$i]} " | jq " .txs" )
156
175
if [ -z " ${txs} " ]; then
@@ -159,21 +178,19 @@ function transfer() {
159
178
fi
160
179
done
161
180
162
- sleep 2
163
181
echo " =========== # withdraw ============="
164
- hash=$( ${CLI} send bty send_exec -a 2 -n deposit -e ticket -k CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944)
182
+ hash=$( ${CLI} send bty transfer -a 2 -n deposit -t 1wvmD6RNHzwhY4eN75WnM6JcaAvNQ4nHx -k CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944)
165
183
echo " ${hash} "
166
- sleep 20
167
- before=$( ${CLI} account balance -a 14KEKbYtKKQm4wMthSK9J4La4nAiidGozt -e ticket | jq " .balance" )
168
- before=$( echo " $before " | bc)
169
- if [ " ${before} " == 0.0000 ]; then
184
+ block_wait " ${CLI} " 1
185
+ before=$( ${CLI} account balance -a 14KEKbYtKKQm4wMthSK9J4La4nAiidGozt -e retrieve | jq -r " .balance" )
186
+ if [ " ${before} " == " 0.0000" ]; then
170
187
echo " wrong ticket balance, should not be zero"
171
188
exit 1
172
189
fi
173
190
174
- hash=$( ${CLI} send bty withdraw -a 1 -n withdraw -e ticket -k CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944)
191
+ hash=$( ${CLI} send bty withdraw -a 1 -n withdraw -e retrieve -k CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944)
175
192
echo " ${hash} "
176
- sleep 25
193
+ block_wait " ${CLI} " 1
177
194
txs=$( ${CLI} tx query_hash -s " ${hash} " | jq " .txs" )
178
195
if [ " ${txs} " == " null" ]; then
179
196
echo " withdraw cannot find tx"
0 commit comments