File tree 3 files changed +23
-8
lines changed
3 files changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -182,18 +182,33 @@ ledger_shutdown() {
182
182
183
183
# Check the chaincode's response (ResponseData) of
184
184
# peer chaincode invoke/query
185
- # (executed via 'try_r' macro) against expected result.
185
+ # (executed via 'try_r/try_out_r ' macro) against expected result.
186
186
# In case of failures, tries to increment integer variable NUM_FAILURES. Increment in all cases NUM_TESTS
187
187
check_result () {
188
- if [[ ${RESPONSE} == " $1 " ]]; then
188
+ if [ " ${RESPONSE_TYPE} " == " out+err" ]; then
189
+ CI_RESPONSE=$( parse_invoke_result_from_log " ${RESPONSE} " )
190
+ CONTEXT=" context: '${RESPONSE} '"
191
+ else
192
+ CI_RESPONSE=" ${RESPONSE} "
193
+ CONTEXT=" "
194
+ fi
195
+
196
+ if [[ ${CI_RESPONSE} == " $1 " ]]; then
189
197
gecho " PASSED"
190
198
else
191
- recho " FAILED (expected '${1} ', got '${RESPONSE} ' )"
199
+ recho " FAILED (expected '${1} ', got '${CI_RESPONSE} ' ${CONTEXT} )"
192
200
export NUM_FAILURES=$(( $NUM_FAILURES + 1 ))
193
201
fi
194
202
export NUM_TESTS=$(( $NUM_TESTS + 1 ))
195
203
}
196
204
205
+ parse_invoke_result_from_log () {
206
+ RESPONSE=" $1 "
207
+ RESPONSE=${RESPONSE##* payload: \" }
208
+ RESPONSE=${RESPONSE%% \" * }
209
+ echo " ${RESPONSE} "
210
+ }
211
+
197
212
198
213
# "Main"
199
214
parse_fabric_config " ${FABRIC_CFG_PATH} "
Original file line number Diff line number Diff line change @@ -75,11 +75,11 @@ try_fail() {
75
75
# Variant of try which stores commands stdout and stderr (or only stdout) in variable RESPONSE
76
76
try_r () {
77
77
say " $@ "
78
- export RESPONSE=$( " $@ " 2>&1 ) || die " test failed: $* "
78
+ export RESPONSE=$( " $@ " 2>&1 ) RESPONSE_TYPE= " out+err " || die " test failed: $* "
79
79
}
80
80
81
81
try_out_r () {
82
82
say " $@ "
83
- export RESPONSE=$( " $@ " ) || die " test failed: $* "
83
+ export RESPONSE=$( " $@ " ) RESPONSE_TYPE= " out " || die " test failed: $* "
84
84
}
85
85
Original file line number Diff line number Diff line change @@ -666,9 +666,9 @@ handle_chaincode_call() {
666
666
if [ ! -z ${DO_WAIT_TIMEOUT+x} ]; then
667
667
opt_arg=" --waitForEvent ${opt_arg} "
668
668
fi
669
- try_out_r $RUN ${FABRIC_BIN_DIR} /peer chaincode invoke " ${OTHER_ARGS[@]} " ${opt_arg} -C ${CHAN_ID} -n ${CC_ID} -c ' {"Args":["__endorse", "' ${encrypted_response} ' "]}'
670
- endorse_response=" ${RESPONSE} "
671
- [ ${endorse_response} == " OK" ] || die " endorsement failed: '${endorse_response} '"
669
+ try_r $RUN ${FABRIC_BIN_DIR} /peer chaincode invoke " ${OTHER_ARGS[@]} " ${opt_arg} -C ${CHAN_ID} -n ${CC_ID} -c ' {"Args":["__endorse", "' ${encrypted_response} ' "]}'
670
+ endorse_response=$( parse_invoke_result_from_log " ${RESPONSE} " )
671
+ [ " ${endorse_response} " == " OK" ] || die " endorsement failed: '${endorse_response} '"
672
672
[ -z ${DEBUG+x} ] || say " endorsement returned '${endorse_response} '"
673
673
fi
674
674
# - return decrypted response
You can’t perform that action at this time.
0 commit comments