Skip to content

Commit

Permalink
QueryApprovalStatus -> SimulateCommitChaincodeDef
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
wlahti committed Jul 2, 2019
1 parent 0acd3eb commit 0254d67
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 64 deletions.
14 changes: 7 additions & 7 deletions first-network/scripts/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,21 @@ if [ "${NO_CHAINCODE}" != "true" ]; then
## approve the definition for org1
approveForMyOrg 1 0 1

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

## now approve also for org2
approveForMyOrg 1 0 2

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

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

## query on both orgs to see that the definition committed ok
## query on both orgs to see that the definition committed successfully
queryCommitted 1 0 1
queryCommitted 1 0 2

Expand Down
14 changes: 7 additions & 7 deletions first-network/scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,14 @@ commitChaincodeDefinition() {
echo
}

# queryStatus VERSION PEER ORG
queryStatus() {
# simulateCommitChaincodeDefinition VERSION PEER ORG
simulateCommitChaincodeDefinition() {
VERSION=$1
PEER=$2
ORG=$3
shift 3
setGlobals $PEER $ORG
echo "===================== Querying approval status on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'... ===================== "
echo "===================== Simulating the commit of the chaincode definition on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'... ===================== "
local rc=1
local starttime=$(date +%s)

Expand All @@ -228,9 +228,9 @@ queryStatus() {
test "$(($(date +%s) - starttime))" -lt "$TIMEOUT" -a $rc -ne 0
do
sleep $DELAY
echo "Attempting to Query approval status on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
echo "Attempting to simulate committing the chaincode definition on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
set -x
peer lifecycle chaincode queryapprovalstatus --channelID $CHANNEL_NAME --name mycc $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --init-required >&log.txt
peer lifecycle chaincode simulatecommit --channelID $CHANNEL_NAME --name mycc $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --init-required >&log.txt
res=$?
set +x
test $res -eq 0 || continue
Expand All @@ -243,9 +243,9 @@ queryStatus() {
echo
cat log.txt
if test $rc -eq 0; then
echo "===================== Query approval status successful on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' ===================== "
echo "===================== Simulating the commit of the chaincode definition successful on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' ===================== "
else
echo "!!!!!!!!!!!!!!! Query approval status result on peer${PEER}.org${ORG} is INVALID !!!!!!!!!!!!!!!!"
echo "!!!!!!!!!!!!!!! Simulate commit chaincode definition result on peer${PEER}.org${ORG} is INVALID !!!!!!!!!!!!!!!!"
echo "================== ERROR !!! FAILED to execute End-2-End Scenario =================="
echo
exit 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ setGlobals() {
fi
}

queryStatus() {
simulateCommitChaincodeDefinition() {
VERSION=$1
PEER=$2
ORG=$3
shift 3
setGlobals $PEER $ORG
echo "===================== Querying approval status on peer${PEER}.org${ORG} ===================== "
echo "===================== Simulating the commit of the chaincode definition on peer${PEER}.org${ORG} ===================== "
local rc=1
local starttime=$(date +%s)

Expand All @@ -51,9 +51,9 @@ queryStatus() {
test "$(($(date +%s) - starttime))" -lt "$TIMEOUT" -a $rc -ne 0
do
sleep $DELAY
echo "Attempting to Query approval status on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
echo "Attempting to simulate committing the chaincode definition on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
set -x
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
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
res=$?
set +x
test $res -eq 0 || continue
Expand All @@ -66,9 +66,9 @@ queryStatus() {
echo
cat log.txt
if test $rc -eq 0; then
echo "===================== Query approval status successful on peer${PEER}.org${ORG} ===================== "
echo "===================== Simulating the commit of the chaincode definition successful on peer${PEER}.org${ORG} ===================== "
else
echo "!!!!!!!!!!!!!!! Query approval status result on peer${PEER}.org${ORG} is INVALID !!!!!!!!!!!!!!!!"
echo "!!!!!!!!!!!!!!! Simulate commit chaincode definition result on peer${PEER}.org${ORG} is INVALID !!!!!!!!!!!!!!!!"
echo "================== ERROR !!! FAILED to execute End-2-End Scenario =================="
echo
exit 1
Expand Down
38 changes: 0 additions & 38 deletions interest_rate_swaps/network/scripts/query-status.sh

This file was deleted.

12 changes: 6 additions & 6 deletions interest_rate_swaps/network/scripts/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ approveChaincode() {
done
}

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

Expand Down Expand Up @@ -162,11 +162,11 @@ queryPackage
echo "Approving chaincode..."
approveChaincode

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

# Query approval status
echo "querying approval status..."
queryApproved
# Simulate committing the chaincode definition
echo "Simulate committing the chaincode definition..."
simulateCommitChaincode

# Commit chaincode definition
echo "Committing chaincode definition..."
Expand Down
38 changes: 38 additions & 0 deletions interest_rate_swaps/network/scripts/simulate-commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# Copyright IBM Corp All Rights Reserved
#
# SPDX-License-Identifier: Apache-2.0
#
simulateCommit() {
echo "===================== Simulating the commit of the chaincode definition for ${CORE_PEER_LOCALMSPID} ===================== "
local rc=1
local starttime=$(date +%s)

# continue to poll
# we either get a successful response, or reach TIMEOUT
while
test "$(($(date +%s) - starttime))" -lt "$TIMEOUT" -a $rc -ne 0
do
echo "Attempting to simulate committing the chaincode definition for ${CORE_PEER_LOCALMSPID} ...$(($(date +%s) - starttime)) secs"
set -x
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
res=$?
set +x
test $res -eq 0 || continue
let rc=0
for var in "$@"
do
grep "$var" log.txt &>/dev/null || let rc=1
done
done
echo
cat log.txt
if test $rc -eq 0; then
echo "===================== Simulating the commit of the chaincode definition successful for ${CORE_PEER_LOCALMSPID} ===================== "
else
echo "!!!!!!!!!!!!!!! Simulate commit chaincode definition result for ${CORE_PEER_LOCALMSPID} is INVALID !!!!!!!!!!!!!!!!"
echo "================== ERROR !!! FAILED to execute End-2-End Scenario =================="
echo
exit 1
fi
}

0 comments on commit 0254d67

Please sign in to comment.