Skip to content

Commit 0254d67

Browse files
committed
QueryApprovalStatus -> SimulateCommitChaincodeDef
Update samples now that QueryApprovalStatus has been renamed to SimulateCommitChaincodeDefinition. FAB-15831 #done Change-Id: I4e12ca2c8424bf8d6537e77e1a9de7fd3723636d Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
1 parent 0acd3eb commit 0254d67

File tree

6 files changed

+64
-64
lines changed

6 files changed

+64
-64
lines changed

first-network/scripts/script.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,21 @@ if [ "${NO_CHAINCODE}" != "true" ]; then
101101
## approve the definition for org1
102102
approveForMyOrg 1 0 1
103103

104-
## query the approval status on both orgs, expect org1 to have approved and org2 not to
105-
queryStatus 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": false"
106-
queryStatus 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": false"
104+
## simulate committing the chaincode definition, expect org1 to have approved and org2 not to
105+
simulateCommitChaincodeDefinition 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": false"
106+
simulateCommitChaincodeDefinition 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": false"
107107

108108
## now approve also for org2
109109
approveForMyOrg 1 0 2
110110

111-
## query the approval status on both orgs, expect them both to have approved
112-
queryStatus 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": true"
113-
queryStatus 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": true"
111+
## simulate committing the chaincode definition again, expect them both to have approved
112+
simulateCommitChaincodeDefinition 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": true"
113+
simulateCommitChaincodeDefinition 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": true"
114114

115115
## now that we know for sure both orgs have approved, commit the definition
116116
commitChaincodeDefinition 1 0 1 0 2
117117

118-
## query on both orgs to see that the definition committed ok
118+
## query on both orgs to see that the definition committed successfully
119119
queryCommitted 1 0 1
120120
queryCommitted 1 0 2
121121

first-network/scripts/utils.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,14 @@ commitChaincodeDefinition() {
211211
echo
212212
}
213213

214-
# queryStatus VERSION PEER ORG
215-
queryStatus() {
214+
# simulateCommitChaincodeDefinition VERSION PEER ORG
215+
simulateCommitChaincodeDefinition() {
216216
VERSION=$1
217217
PEER=$2
218218
ORG=$3
219219
shift 3
220220
setGlobals $PEER $ORG
221-
echo "===================== Querying approval status on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'... ===================== "
221+
echo "===================== Simulating the commit of the chaincode definition on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'... ===================== "
222222
local rc=1
223223
local starttime=$(date +%s)
224224

@@ -228,9 +228,9 @@ queryStatus() {
228228
test "$(($(date +%s) - starttime))" -lt "$TIMEOUT" -a $rc -ne 0
229229
do
230230
sleep $DELAY
231-
echo "Attempting to Query approval status on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
231+
echo "Attempting to simulate committing the chaincode definition on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
232232
set -x
233-
peer lifecycle chaincode queryapprovalstatus --channelID $CHANNEL_NAME --name mycc $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --init-required >&log.txt
233+
peer lifecycle chaincode simulatecommit --channelID $CHANNEL_NAME --name mycc $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --init-required >&log.txt
234234
res=$?
235235
set +x
236236
test $res -eq 0 || continue
@@ -243,9 +243,9 @@ queryStatus() {
243243
echo
244244
cat log.txt
245245
if test $rc -eq 0; then
246-
echo "===================== Query approval status successful on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' ===================== "
246+
echo "===================== Simulating the commit of the chaincode definition successful on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' ===================== "
247247
else
248-
echo "!!!!!!!!!!!!!!! Query approval status result on peer${PEER}.org${ORG} is INVALID !!!!!!!!!!!!!!!!"
248+
echo "!!!!!!!!!!!!!!! Simulate commit chaincode definition result on peer${PEER}.org${ORG} is INVALID !!!!!!!!!!!!!!!!"
249249
echo "================== ERROR !!! FAILED to execute End-2-End Scenario =================="
250250
echo
251251
exit 1

high-throughput/scripts/query-status.sh high-throughput/scripts/simulate-commit.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ setGlobals() {
3535
fi
3636
}
3737

38-
queryStatus() {
38+
simulateCommitChaincodeDefinition() {
3939
VERSION=$1
4040
PEER=$2
4141
ORG=$3
4242
shift 3
4343
setGlobals $PEER $ORG
44-
echo "===================== Querying approval status on peer${PEER}.org${ORG} ===================== "
44+
echo "===================== Simulating the commit of the chaincode definition on peer${PEER}.org${ORG} ===================== "
4545
local rc=1
4646
local starttime=$(date +%s)
4747

@@ -51,9 +51,9 @@ queryStatus() {
5151
test "$(($(date +%s) - starttime))" -lt "$TIMEOUT" -a $rc -ne 0
5252
do
5353
sleep $DELAY
54-
echo "Attempting to Query approval status on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
54+
echo "Attempting to simulate committing the chaincode definition on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
5555
set -x
56-
peer lifecycle chaincode queryapprovalstatus --channelID $CHANNEL_NAME --name $CC_NAME --signature-policy "OR('Org1MSP.peer', 'Org2MSP.peer')" --version ${VERSION} --init-required --sequence ${VERSION} >&log.txt
56+
peer lifecycle chaincode simulatecommit --channelID $CHANNEL_NAME --name $CC_NAME --signature-policy "OR('Org1MSP.peer', 'Org2MSP.peer')" --version ${VERSION} --init-required --sequence ${VERSION} >&log.txt
5757
res=$?
5858
set +x
5959
test $res -eq 0 || continue
@@ -66,9 +66,9 @@ queryStatus() {
6666
echo
6767
cat log.txt
6868
if test $rc -eq 0; then
69-
echo "===================== Query approval status successful on peer${PEER}.org${ORG} ===================== "
69+
echo "===================== Simulating the commit of the chaincode definition successful on peer${PEER}.org${ORG} ===================== "
7070
else
71-
echo "!!!!!!!!!!!!!!! Query approval status result on peer${PEER}.org${ORG} is INVALID !!!!!!!!!!!!!!!!"
71+
echo "!!!!!!!!!!!!!!! Simulate commit chaincode definition result on peer${PEER}.org${ORG} is INVALID !!!!!!!!!!!!!!!!"
7272
echo "================== ERROR !!! FAILED to execute End-2-End Scenario =================="
7373
echo
7474
exit 1

interest_rate_swaps/network/scripts/query-status.sh

-38
This file was deleted.

interest_rate_swaps/network/scripts/script.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ approveChaincode() {
7373
done
7474
}
7575

76-
queryApproved() {
76+
simulateCommitChaincode() {
7777
for org in partya partyb partyc auditor rrprovider
7878
do
7979
export CORE_PEER_LOCALMSPID=$org
8080
export CORE_PEER_ADDRESS=irs-$org:7051
8181
export CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/$org.example.com/users/Admin@$org.example.com/msp
82-
queryStatus "\"partya\": true" "\"partyb\": true" "\"partyc\": true" "\"auditor\": true" "\"rrprovider\": true"
82+
simulateCommit "\"partya\": true" "\"partyb\": true" "\"partyc\": true" "\"auditor\": true" "\"rrprovider\": true"
8383
done
8484
}
8585

@@ -162,11 +162,11 @@ queryPackage
162162
echo "Approving chaincode..."
163163
approveChaincode
164164

165-
. scripts/query-status.sh
165+
. scripts/simulate-commit.sh
166166

167-
# Query approval status
168-
echo "querying approval status..."
169-
queryApproved
167+
# Simulate committing the chaincode definition
168+
echo "Simulate committing the chaincode definition..."
169+
simulateCommitChaincode
170170

171171
# Commit chaincode definition
172172
echo "Committing chaincode definition..."
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#
2+
# Copyright IBM Corp All Rights Reserved
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
simulateCommit() {
7+
echo "===================== Simulating the commit of the chaincode definition for ${CORE_PEER_LOCALMSPID} ===================== "
8+
local rc=1
9+
local starttime=$(date +%s)
10+
11+
# continue to poll
12+
# we either get a successful response, or reach TIMEOUT
13+
while
14+
test "$(($(date +%s) - starttime))" -lt "$TIMEOUT" -a $rc -ne 0
15+
do
16+
echo "Attempting to simulate committing the chaincode definition for ${CORE_PEER_LOCALMSPID} ...$(($(date +%s) - starttime)) secs"
17+
set -x
18+
peer lifecycle chaincode simulatecommit -o irs-orderer:7050 --channelID irs --signature-policy "AND(OR('partya.peer','partyb.peer','partyc.peer'), 'auditor.peer')" --name irscc --version 1 --init-required --sequence 1 >&log.txt
19+
res=$?
20+
set +x
21+
test $res -eq 0 || continue
22+
let rc=0
23+
for var in "$@"
24+
do
25+
grep "$var" log.txt &>/dev/null || let rc=1
26+
done
27+
done
28+
echo
29+
cat log.txt
30+
if test $rc -eq 0; then
31+
echo "===================== Simulating the commit of the chaincode definition successful for ${CORE_PEER_LOCALMSPID} ===================== "
32+
else
33+
echo "!!!!!!!!!!!!!!! Simulate commit chaincode definition result for ${CORE_PEER_LOCALMSPID} is INVALID !!!!!!!!!!!!!!!!"
34+
echo "================== ERROR !!! FAILED to execute End-2-End Scenario =================="
35+
echo
36+
exit 1
37+
fi
38+
}

0 commit comments

Comments
 (0)