Skip to content

Commit 583ff8f

Browse files
wlahtiSimon Stone
authored andcommitted
Use renamed CheckCommitReadiness function
FAB-16111 #done Change-Id: Iacdbd59515b71cb692935b0afbd1c678e0f55851 Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
1 parent 750f937 commit 583ff8f

File tree

6 files changed

+64
-62
lines changed

6 files changed

+64
-62
lines changed

first-network/scripts/script.sh

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

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"
104+
## check whether the chaincode definition is ready to be committed
105+
## expect org1 to have approved and org2 not to
106+
checkCommitReadiness 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": false"
107+
checkCommitReadiness 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": false"
107108

108109
## now approve also for org2
109110
approveForMyOrg 1 0 2
110111

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"
112+
## check whether the chaincode definition is ready to be committed
113+
## expect them both to have approved
114+
checkCommitReadiness 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": true"
115+
checkCommitReadiness 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": true"
114116

115117
## now that we know for sure both orgs have approved, commit the definition
116118
commitChaincodeDefinition 1 0 1 0 2
117119

118-
## query on both orgs to see that the definition committed successfully
120+
## query on both orgs to see that the definition committed successfully
119121
queryCommitted 1 0 1
120122
queryCommitted 1 0 2
121123

first-network/scripts/utils.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,14 @@ commitChaincodeDefinition() {
211211
echo
212212
}
213213

214-
# simulateCommitChaincodeDefinition VERSION PEER ORG
215-
simulateCommitChaincodeDefinition() {
214+
# checkCommitReadiness VERSION PEER ORG
215+
checkCommitReadiness() {
216216
VERSION=$1
217217
PEER=$2
218218
ORG=$3
219219
shift 3
220220
setGlobals $PEER $ORG
221-
echo "===================== Simulating the commit of the chaincode definition on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'... ===================== "
221+
echo "===================== Checking the commit readiness 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 @@ simulateCommitChaincodeDefinition() {
228228
test "$(($(date +%s) - starttime))" -lt "$TIMEOUT" -a $rc -ne 0
229229
do
230230
sleep $DELAY
231-
echo "Attempting to simulate committing the chaincode definition on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
231+
echo "Attempting to check the commit readiness of the chaincode definition on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
232232
set -x
233-
peer lifecycle chaincode simulatecommit --channelID $CHANNEL_NAME --name mycc $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --output json --init-required >&log.txt
233+
peer lifecycle chaincode checkcommitreadiness --channelID $CHANNEL_NAME --name mycc $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --output json --init-required >&log.txt
234234
res=$?
235235
set +x
236236
test $res -eq 0 || continue
@@ -243,9 +243,9 @@ simulateCommitChaincodeDefinition() {
243243
echo
244244
cat log.txt
245245
if test $rc -eq 0; then
246-
echo "===================== Simulating the commit of the chaincode definition successful on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' ===================== "
246+
echo "===================== Checking the commit readiness of the chaincode definition successful on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' ===================== "
247247
else
248-
echo "!!!!!!!!!!!!!!! Simulate commit chaincode definition result on peer${PEER}.org${ORG} is INVALID !!!!!!!!!!!!!!!!"
248+
echo "!!!!!!!!!!!!!!! Check commit readiness 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/simulate-commit.sh renamed to high-throughput/scripts/check-commit-readiness.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ setGlobals() {
3535
fi
3636
}
3737

38-
simulateCommitChaincodeDefinition() {
38+
checkCommitReadiness() {
3939
VERSION=$1
4040
PEER=$2
4141
ORG=$3
@@ -51,9 +51,9 @@ simulateCommitChaincodeDefinition() {
5151
test "$(($(date +%s) - starttime))" -lt "$TIMEOUT" -a $rc -ne 0
5252
do
5353
sleep $DELAY
54-
echo "Attempting to simulate committing the chaincode definition on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
54+
echo "Attempting to check the commit readiness of the chaincode definition on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
5555
set -x
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
56+
peer lifecycle chaincode checkcommitreadiness --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 @@ simulateCommitChaincodeDefinition() {
6666
echo
6767
cat log.txt
6868
if test $rc -eq 0; then
69-
echo "===================== Simulating the commit of the chaincode definition successful on peer${PEER}.org${ORG} ===================== "
69+
echo "===================== Checking the commit readiness of the chaincode definition successful on peer${PEER}.org${ORG} ===================== "
7070
else
71-
echo "!!!!!!!!!!!!!!! Simulate commit chaincode definition result on peer${PEER}.org${ORG} is INVALID !!!!!!!!!!!!!!!!"
71+
echo "!!!!!!!!!!!!!!! Check commit readiness result on peer${PEER}.org${ORG} is INVALID !!!!!!!!!!!!!!!!"
7272
echo "================== ERROR !!! FAILED to execute End-2-End Scenario =================="
7373
echo
7474
exit 1
Lines changed: 38 additions & 0 deletions
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+
checkCommitReadiness() {
7+
echo "===================== Check the commit readiness 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 check the commit readiness of the chaincode definition for ${CORE_PEER_LOCALMSPID} ...$(($(date +%s) - starttime)) secs"
17+
set -x
18+
peer lifecycle chaincode checkcommitreadiness -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 "===================== Checking the commit readiness of the chaincode definition successful for ${CORE_PEER_LOCALMSPID} ===================== "
32+
else
33+
echo "!!!!!!!!!!!!!!! Check commit readiness 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+
}

interest_rate_swaps/network/scripts/script.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ approveChaincode() {
7373
done
7474
}
7575

76-
simulateCommitChaincode() {
76+
checkCommitReadiness() {
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-
simulateCommit "\"partya\": true" "\"partyb\": true" "\"partyc\": true" "\"auditor\": true" "\"rrprovider\": true"
82+
checkCommitReadiness "\"partya\": true" "\"partyb\": true" "\"partyc\": true" "\"auditor\": true" "\"rrprovider\": true"
8383
done
8484
}
8585

@@ -164,9 +164,9 @@ approveChaincode
164164

165165
. scripts/simulate-commit.sh
166166

167-
# Simulate committing the chaincode definition
168-
echo "Simulate committing the chaincode definition..."
169-
simulateCommitChaincode
167+
# Check the commit readiness of the chaincode definition
168+
echo "Checking the commit readiness of the chaincode definition..."
169+
checkCommitReadiness
170170

171171
# Commit chaincode definition
172172
echo "Committing chaincode definition..."

interest_rate_swaps/network/scripts/simulate-commit.sh

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)