Skip to content

Commit 0e6068f

Browse files
committed
Fixed docker-compose.sh
Former-commit-id: 4b3205ae3fc11ace2a241f0868f4f527a7c2099a Former-commit-id: 60590b0
1 parent e346b3e commit 0e6068f

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

.clang-format

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ TabWidth: '4'
1818
ReflowComments: 'true'
1919
SortIncludes: 'true'
2020
AllowShortFunctionsOnASingleLine: 'Empty'
21-
AllowShortIfStatementsOnASingleLine: 'true'
21+
AllowShortIfStatementsOnASingleLine: 'true'

build/docker-compose.sh

+30-13
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ fi
2020

2121
function init() {
2222
# update test environment
23+
sed -i $sedfix 's/^Title.*/Title="local"/g' chain33.toml
2324
sed -i $sedfix 's/^TestNet=.*/TestNet=true/g' chain33.toml
2425

2526
# p2p
@@ -136,21 +137,39 @@ function init() {
136137
# ${CLI} mempool last_txs
137138
}
138139

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+
139159
function transfer() {
140160
echo "=========== # transfer ============="
141161
hashes=()
142162
for ((i = 0; i < 10; i++)); do
143163
hash=$(${CLI} send bty transfer -a 1 -n test -t 14KEKbYtKKQm4wMthSK9J4La4nAiidGozt -k 4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01)
144-
hashes=("${hashes[*]}" "$hash")
145-
sleep 1
164+
hashes=("${hashes[@]}" "$hash")
146165
done
166+
block_wait "${CLI}" 1
147167
echo "len: ${#hashes[@]}"
148-
if [ ${#hashes[*]} != 10 ]; then
149-
echo tx number wrong
168+
if [ "${#hashes[@]}" != 10 ]; then
169+
echo "tx number wrong"
150170
exit 1
151171
fi
152172

153-
sleep 20
154173
for ((i = 0; i < ${#hashes[*]}; i++)); do
155174
txs=$(${CLI} tx query_hash -s "${hashes[$i]}" | jq ".txs")
156175
if [ -z "${txs}" ]; then
@@ -159,21 +178,19 @@ function transfer() {
159178
fi
160179
done
161180

162-
sleep 2
163181
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)
165183
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
170187
echo "wrong ticket balance, should not be zero"
171188
exit 1
172189
fi
173190

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)
175192
echo "${hash}"
176-
sleep 25
193+
block_wait "${CLI}" 1
177194
txs=$(${CLI} tx query_hash -s "${hash}" | jq ".txs")
178195
if [ "${txs}" == "null" ]; then
179196
echo "withdraw cannot find tx"

0 commit comments

Comments
 (0)