Skip to content

Commit 2488685

Browse files
committed
#303 Upgrade Cosmos-SDK to v0.47.3
- Temporary comment passed tests Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com> Signed-off-by: Abdulbois <abdulbois123@gmail.com>
1 parent fabb960 commit 2488685

File tree

4 files changed

+268
-44
lines changed

4 files changed

+268
-44
lines changed

integration_tests/run-all.sh

+21-21
Original file line numberDiff line numberDiff line change
@@ -128,26 +128,26 @@ cleanup_pool
128128
#fi
129129

130130
# Light Client Proxy Cli shell tests
131-
if [[ $TESTS_TO_RUN =~ "all" || $TESTS_TO_RUN =~ "light" ]]; then
132-
CLI_SHELL_TESTS=$(find integration_tests/light_client_proxy -type f -name '*.sh' -not -name "common.sh" | sort)
133-
134-
for CLI_SHELL_TEST in ${CLI_SHELL_TESTS}; do
135-
init_pool
136-
137-
log "*****************************************************************************************"
138-
log "Running $CLI_SHELL_TEST"
139-
log "*****************************************************************************************"
140-
141-
if bash "$CLI_SHELL_TEST" &>${DETAILED_OUTPUT_TARGET}; then
142-
log "$CLI_SHELL_TEST finished successfully"
143-
else
144-
log "$CLI_SHELL_TEST failed"
145-
exit 1
146-
fi
147-
148-
cleanup_pool
149-
done
150-
fi
131+
#if [[ $TESTS_TO_RUN =~ "all" || $TESTS_TO_RUN =~ "light" ]]; then
132+
# CLI_SHELL_TESTS=$(find integration_tests/light_client_proxy -type f -name '*.sh' -not -name "common.sh" | sort)
133+
#
134+
# for CLI_SHELL_TEST in ${CLI_SHELL_TESTS}; do
135+
# init_pool
136+
#
137+
# log "*****************************************************************************************"
138+
# log "Running $CLI_SHELL_TEST"
139+
# log "*****************************************************************************************"
140+
#
141+
# if bash "$CLI_SHELL_TEST" &>${DETAILED_OUTPUT_TARGET}; then
142+
# log "$CLI_SHELL_TEST finished successfully"
143+
# else
144+
# log "$CLI_SHELL_TEST failed"
145+
# exit 1
146+
# fi
147+
#
148+
# cleanup_pool
149+
# done
150+
#fi
151151

152152
# Go rest tests
153153
#if [[ $TESTS_TO_RUN =~ "all" || $TESTS_TO_RUN =~ "rest" ]]; then
@@ -188,7 +188,7 @@ fi
188188

189189
# Upgrade procedure tests
190190
if [[ $TESTS_TO_RUN =~ "all" || $TESTS_TO_RUN =~ "upgrade" ]]; then
191-
UPGRADE_SHELL_TESTS=$(find integration_tests/upgrade -type f -name '*.sh' -not -name "add-new-node-after-upgrade.sh" | sort)
191+
UPGRADE_SHELL_TESTS=$(find integration_tests/upgrade -type f -name '*.sh' -not -name "add-new-node-after-upgrade.sh" -not -name "common.sh" | sort)
192192

193193
for UPGRADE_SHELL_TEST in ${UPGRADE_SHELL_TESTS}; do
194194
log "*****************************************************************************************"

integration_tests/upgrade/common.sh

+241
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
#!/bin/bash
2+
# Copyright 2020 DSR Corporation
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -euo pipefail
17+
18+
# common constants
19+
node_p2p_port=26670
20+
node_client_port=26671
21+
chain_id="dclchain"
22+
node0conn="tcp://192.167.10.2:26657"
23+
docker_network="distributed-compliance-ledger_localnet"
24+
passphrase="test1234"
25+
LOCALNET_DIR=".localnet"
26+
27+
# RED=`tput setaf 1`
28+
# GREEN=`tput setaf 2`
29+
# RESET=`tput sgr0`
30+
GREEN=""
31+
RED=""
32+
RESET=""
33+
34+
random_string() {
35+
local __resultvar="$1"
36+
local length=${2:-6} # Default is 6
37+
# Newer mac might have shasum instead of sha1sum
38+
if command -v shasum &> /dev/null
39+
then
40+
eval $__resultvar="'$(date +%s.%N | shasum | fold -w ${length} | head -n 1)'"
41+
else
42+
eval $__resultvar="'$(date +%s.%N | sha1sum | fold -w ${length} | head -n 1)'"
43+
fi
44+
}
45+
46+
DEF_OUTPUT_MODE=json
47+
48+
49+
# json: pretty (indented) json
50+
# raw or otherwise: raw
51+
_check_response() {
52+
local _result="$1"
53+
local _expected_string="$2"
54+
local _mode="${3:-$DEF_OUTPUT_MODE}"
55+
56+
if [[ "$_mode" == "json" ]]; then
57+
if [[ -n "$(echo "$_result" | jq | grep "$_expected_string" 2>/dev/null)" ]]; then
58+
echo true
59+
return
60+
fi
61+
else
62+
if [[ -n "$(echo "$_result" | grep "$_expected_string" 2>/dev/null)" ]]; then
63+
echo true
64+
return
65+
fi
66+
fi
67+
68+
echo false
69+
}
70+
71+
check_response() {
72+
local _result="$1"
73+
local _expected_string="$2"
74+
local _mode="${3:-$DEF_OUTPUT_MODE}"
75+
76+
if [[ "$(_check_response "$_result" "$_expected_string" "$_mode")" != true ]]; then
77+
echo "${GREEN}ERROR:${RESET} command failed. The expected string: '$_expected_string' not found in the result: $_result"
78+
exit 1
79+
fi
80+
}
81+
82+
check_response_and_report() {
83+
local _result="$1"
84+
local _expected_string="$2"
85+
local _mode="${3:-$DEF_OUTPUT_MODE}"
86+
87+
check_response "$_result" "$_expected_string" "$_mode"
88+
echo "${GREEN}SUCCESS: ${RESET} Result contains expected substring: '$_expected_string'"
89+
}
90+
91+
response_does_not_contain() {
92+
local _result="$1"
93+
local _unexpected_string="$2"
94+
local _mode="${3:-$DEF_OUTPUT_MODE}"
95+
96+
if [[ "$(_check_response "$_result" "$_unexpected_string" "$_mode")" == true ]]; then
97+
echo "ERROR: command failed. The unexpected string: '$_unexpected_string' found in the result: $_result"
98+
exit 1
99+
fi
100+
101+
echo "${GREEN}SUCCESS: ${RESET}Result does not contain unexpected substring: '$_unexpected_string'"
102+
}
103+
104+
create_new_account(){
105+
local __resultvar="$1"
106+
random_string name
107+
eval $__resultvar="'$name'"
108+
109+
local roles="$2"
110+
111+
echo "Account name: $name"
112+
113+
echo "Generate key for $name"
114+
(echo $passphrase; echo $passphrase) | dcld keys add "$name"
115+
116+
address=$(echo $passphrase | dcld keys show $name -a)
117+
pubkey=$(echo $passphrase | dcld keys show $name -p)
118+
119+
echo "Jack proposes account for \"$name\" with roles: \"$roles\""
120+
result=$(echo $passphrase | dcld tx auth propose-add-account --address="$address" --pubkey="$pubkey" --roles=$roles --from jack --yes)
121+
check_response "$result" "\"code\": 0"
122+
echo "$result"
123+
124+
echo "Alice approves account for \"$name\" with roles: \"$roles\""
125+
result=$(echo $passphrase | dcld tx auth approve-add-account --address="$address" --from alice --yes)
126+
check_response "$result" "\"code\": 0"
127+
echo "$result"
128+
}
129+
130+
create_new_vendor_account(){
131+
132+
local _name="$1"
133+
local _vid="$2"
134+
135+
echo $passphrase | dcld keys add "$_name"
136+
_address=$(echo $passphrase | dcld keys show $_name -a)
137+
_pubkey=$(echo $passphrase | dcld keys show $_name -p)
138+
139+
local _result=""
140+
if [ $# -eq 3 ]; then
141+
local _pid_ranges="$3"
142+
echo "Jack proposes account for \"$_name\" with Vendor role and with [$_pid_ranges] associated Product IDs"
143+
_result=$(echo $passphrase | dcld tx auth propose-add-account --address="$_address" --pubkey="$_pubkey" --roles=Vendor --vid=$_vid --pid_ranges=$_pid_ranges --from jack --yes)
144+
else
145+
echo "Jack proposes account for \"$_name\" with Vendor role"
146+
_result=$(echo $passphrase | dcld tx auth propose-add-account --address="$_address" --pubkey="$_pubkey" --roles=Vendor --vid=$_vid --from jack --yes)
147+
fi
148+
}
149+
150+
151+
test_divider() {
152+
echo ""
153+
echo "--------------------------"
154+
echo ""
155+
}
156+
157+
get_height() {
158+
local __resultvar="$1"
159+
eval $__resultvar="'$(dcld status | jq | grep latest_block_height | awk -F'"' '{print $4}')'"
160+
}
161+
162+
wait_for_height() {
163+
local target_height="${1:-1}" # Default is 1
164+
local wait_time="${2:-10}" # In seconds, default - 10
165+
local mode="${3:-normal}" # normal or outage-safe
166+
local node="${4:-""}"
167+
168+
local _output=${DETAILED_OUTPUT_TARGET:-/dev/stdout}
169+
170+
local waited=0
171+
local wait_interval=1
172+
173+
if [[ -n "$node" ]]; then
174+
node="--node $node"
175+
fi
176+
177+
while true; do
178+
sleep "${wait_interval}"
179+
waited=$((waited + wait_interval))
180+
181+
if [[ "$mode" == "outage-safe" ]]; then
182+
current_height="$(dcld status $node 2>/dev/null | jq | grep latest_block_height | awk -F'"' '{print $4}')" || true
183+
else
184+
current_height="$(dcld status $node | jq | grep latest_block_height | awk -F'"' '{print $4}')"
185+
186+
if [[ -z "$current_height" ]]; then
187+
echo "No height found in status"
188+
exit 1
189+
fi
190+
fi
191+
192+
if [[ -n "$current_height" ]] && ((current_height >= target_height)); then
193+
echo "Height $target_height is reached in $waited seconds" &>${_output}
194+
break
195+
fi
196+
197+
if ((waited > wait_time)); then
198+
echo "Height $target_height is not reached in $wait_time seconds"
199+
exit 1
200+
fi
201+
202+
echo "Waiting for height: $target_height... Current height: ${current_height:-unavailable}, " \
203+
"wait time: $waited, time limit: $wait_time." &>${_output}
204+
done
205+
}
206+
207+
get_txn_result() {
208+
local _broadcast_result=${1}
209+
local _txHash=$(echo "$_broadcast_result" | jq -r '.txhash')
210+
local _command="dcld query tx $_txHash"
211+
local _result=$($_command 2>&1)
212+
213+
for i in {1..20}; do
214+
if [[ "$(_check_response "$_result" "not found" "raw")" == true ]]; then
215+
sleep 2
216+
_result=$($_command 2>&1)
217+
else
218+
break
219+
fi
220+
done
221+
222+
echo "$_result"
223+
}
224+
225+
execute_with_retry() {
226+
local _command=${1}
227+
local _error=${2:-"EOF"}
228+
local _result=$($_command)
229+
230+
for i in {1..20}; do
231+
if [[ "$(_check_response "$_result" $_error "raw")" == true ]]; then
232+
#echo "EOF detected, re-trying"
233+
sleep 2
234+
_result=$($_command)
235+
else
236+
break
237+
fi
238+
done
239+
240+
echo "$_result"
241+
}

integration_tests/upgrade/test-upgrade-0.12-to-1.2.sh

+4-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# limitations under the License.
1515

1616
set -euo pipefail
17-
source integration_tests/cli/common.sh
17+
source integration_tests/upgrade/common.sh
1818

1919
binary_version_old="v0.12.0"
2020
binary_version_new="v1.2.2"
@@ -45,8 +45,6 @@ else
4545
DETAILED_OUTPUT_TARGET=/dev/null
4646
fi
4747

48-
source integration_tests/cli/common.sh
49-
5048
log() {
5149
echo "${LOG_PREFIX}$1"
5250
}
@@ -77,6 +75,7 @@ start_pool() {
7775
make localnet_start &>${DETAILED_OUTPUT_TARGET}
7876

7977
log "-> Waiting for the second block (needed to request proofs)" >${DETAILED_OUTPUT_TARGET}
78+
execute_with_retry "dcld status" "connection refused"
8079
wait_for_height 2 20
8180
}
8281

@@ -162,7 +161,6 @@ add_validator_node() {
162161
set -eu; echo test1234 | dcld tx validator add-node --pubkey='$vpubkey' --moniker="$node_name" --from="$account" --yes
163162
EOF
164163
result="$(docker exec "$container" /bin/sh -c "echo test1234 | ./dcld tx validator add-node --pubkey='$vpubkey' --moniker="$node_name" --from="$account" --yes")"
165-
result=$(get_txn_result "$result")
166164
check_response "$result" "\"code\": 0"
167165
echo "$result"
168166

@@ -257,6 +255,8 @@ company_legal_name="LegalCompanyName"
257255
company_preferred_name="CompanyPreferredName"
258256
vendor_landing_page_url="https://www.example.com"
259257

258+
dcld config broadcast-mode block
259+
260260
random_string user_1
261261
echo "$user_1 generates keys"
262262
cmd="(echo $passphrase; echo $passphrase) | $DCLD_BIN_OLD keys add $user_1"
@@ -553,15 +553,13 @@ test_divider
553553
echo "Disable node"
554554
# FIXME: use proper binary (not dcld but $DCLD_BIN_OLD)
555555
result=$(docker exec "$container" /bin/sh -c "echo test1234 | dcld tx validator disable-node --from=$account --yes")
556-
result=$(get_txn_result "$result")
557556
check_response "$result" "\"code\": 0"
558557

559558
test_divider
560559

561560
echo "Enable node"
562561
# FIXME: use proper binary (not dcld but $DCLD_BIN_OLD)
563562
result=$(docker exec "$container" /bin/sh -c "echo test1234 | dcld tx validator enable-node --from=$account --yes")
564-
result=$(get_txn_result "$result")
565563
check_response "$result" "\"code\": 0"
566564

567565
test_divider
@@ -587,7 +585,6 @@ test_divider
587585
echo "Enable node"
588586
# FIXME: use proper binary (not dcld but $DCLD_BIN_OLD)
589587
result=$(docker exec "$container" /bin/sh -c "echo test1234 | dcld tx validator enable-node --from=$account --yes")
590-
result=$(get_txn_result "$result")
591588
check_response "$result" "\"code\": 0"
592589

593590
test_divider
@@ -1301,15 +1298,13 @@ test_divider
13011298
echo "Disable node"
13021299
# FIXME: use proper binary (not dcld but $DCLD_BIN_OLD)
13031300
result=$(docker exec "$container" /bin/sh -c "echo test1234 | dcld tx validator disable-node --from=$account --yes")
1304-
result=$(get_txn_result "$result")
13051301
check_response "$result" "\"code\": 0"
13061302

13071303
test_divider
13081304

13091305
echo "Enable node"
13101306
# FIXME: use proper binary (not dcld but $DCLD_BIN_OLD)
13111307
result=$(docker exec "$container" /bin/sh -c "echo test1234 | dcld tx validator enable-node --from=$account --yes")
1312-
result=$(get_txn_result "$result")
13131308
check_response "$result" "\"code\": 0"
13141309

13151310
test_divider
@@ -1335,7 +1330,6 @@ test_divider
13351330
echo "Enable node"
13361331
# FIXME: use proper binary (not dcld but $DCLD_BIN_OLD)
13371332
result=$(docker exec "$container" /bin/sh -c "echo test1234 | dcld tx validator enable-node --from=$account --yes")
1338-
result=$(get_txn_result "$result")
13391333
check_response "$result" "\"code\": 0"
13401334

13411335
test_divider

0 commit comments

Comments
 (0)