mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-23 01:55:10 +00:00
first-network/scripts/*: Make Chaincode name configurable
1. The idea is to use this generic functions for managing any chaincode lifecycle inside cli container. E.g. ''' source scripts/utils.sh packageChaincode 1 0 1 myapp installChaincode 0 1 myapp approveForMyOrg 1 0 1 myapp .... ''' Signed-off-by: Anoop Vijayan Maniankara <anoop@tuxera.com>
This commit is contained in:
parent
4208644416
commit
0307743add
6 changed files with 66 additions and 43 deletions
|
|
@ -15,12 +15,14 @@ CC_SRC_LANGUAGE="$3"
|
||||||
TIMEOUT="$4"
|
TIMEOUT="$4"
|
||||||
VERBOSE="$5"
|
VERBOSE="$5"
|
||||||
NO_CHAINCODE="$6"
|
NO_CHAINCODE="$6"
|
||||||
|
NAME="$7"
|
||||||
: ${CHANNEL_NAME:="mychannel"}
|
: ${CHANNEL_NAME:="mychannel"}
|
||||||
: ${DELAY:="3"}
|
: ${DELAY:="3"}
|
||||||
: ${CC_SRC_LANGUAGE:="go"}
|
: ${CC_SRC_LANGUAGE:="go"}
|
||||||
: ${TIMEOUT:="10"}
|
: ${TIMEOUT:="10"}
|
||||||
: ${VERBOSE:="false"}
|
: ${VERBOSE:="false"}
|
||||||
: ${NO_CHAINCODE:="false"}
|
: ${NO_CHAINCODE:="false"}
|
||||||
|
: ${NAME:="mycc"}
|
||||||
CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]`
|
CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]`
|
||||||
COUNTER=1
|
COUNTER=1
|
||||||
MAX_RETRY=20
|
MAX_RETRY=20
|
||||||
|
|
@ -43,6 +45,7 @@ fi
|
||||||
|
|
||||||
|
|
||||||
echo "Channel name : "$CHANNEL_NAME
|
echo "Channel name : "$CHANNEL_NAME
|
||||||
|
echo "Chaincode name : "$NAME
|
||||||
|
|
||||||
# import utils
|
# import utils
|
||||||
. scripts/utils.sh
|
. scripts/utils.sh
|
||||||
|
|
@ -95,62 +98,62 @@ updateAnchorPeers 0 2
|
||||||
if [ "${NO_CHAINCODE}" != "true" ]; then
|
if [ "${NO_CHAINCODE}" != "true" ]; then
|
||||||
|
|
||||||
## at first we package the chaincode
|
## at first we package the chaincode
|
||||||
packageChaincode 1 0 1
|
packageChaincode 1 0 1 $NAME
|
||||||
|
|
||||||
## Install chaincode on peer0.org1 and peer0.org2
|
## Install chaincode on peer0.org1 and peer0.org2
|
||||||
echo "Installing chaincode on peer0.org1..."
|
echo "Installing chaincode on peer0.org1..."
|
||||||
installChaincode 0 1
|
installChaincode 0 1 $NAME
|
||||||
echo "Install chaincode on peer0.org2..."
|
echo "Install chaincode on peer0.org2..."
|
||||||
installChaincode 0 2
|
installChaincode 0 2 $NAME
|
||||||
|
|
||||||
## query whether the chaincode is installed
|
## query whether the chaincode is installed
|
||||||
queryInstalled 0 1
|
queryInstalled 0 1
|
||||||
|
|
||||||
## approve the definition for org1
|
## approve the definition for org1
|
||||||
approveForMyOrg 1 0 1
|
approveForMyOrg 1 0 1 $NAME
|
||||||
|
|
||||||
## check whether the chaincode definition is ready to be committed
|
## check whether the chaincode definition is ready to be committed
|
||||||
## expect org1 to have approved and org2 not to
|
## expect org1 to have approved and org2 not to
|
||||||
checkCommitReadiness 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": false"
|
checkCommitReadiness 1 0 1 $NAME "\"Org1MSP\": true" "\"Org2MSP\": false"
|
||||||
checkCommitReadiness 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": false"
|
checkCommitReadiness 1 0 2 $NAME "\"Org1MSP\": true" "\"Org2MSP\": false"
|
||||||
|
|
||||||
## now approve also for org2
|
## now approve also for org2
|
||||||
approveForMyOrg 1 0 2
|
approveForMyOrg 1 0 2 $NAME
|
||||||
|
|
||||||
## check whether the chaincode definition is ready to be committed
|
## check whether the chaincode definition is ready to be committed
|
||||||
## expect them both to have approved
|
## expect them both to have approved
|
||||||
checkCommitReadiness 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": true"
|
checkCommitReadiness 1 0 1 $NAME "\"Org1MSP\": true" "\"Org2MSP\": true"
|
||||||
checkCommitReadiness 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": true"
|
checkCommitReadiness 1 0 2 $NAME "\"Org1MSP\": true" "\"Org2MSP\": true"
|
||||||
|
|
||||||
## now that we know for sure both orgs have approved, commit the definition
|
## now that we know for sure both orgs have approved, commit the definition
|
||||||
commitChaincodeDefinition 1 0 1 0 2
|
commitChaincodeDefinition 1 $NAME 0 1 0 2
|
||||||
|
|
||||||
## query on both orgs to see that the definition committed successfully
|
## query on both orgs to see that the definition committed successfully
|
||||||
queryCommitted 1 0 1
|
queryCommitted 1 0 1 $NAME
|
||||||
queryCommitted 1 0 2
|
queryCommitted 1 0 2 $NAME
|
||||||
|
|
||||||
# invoke init
|
# invoke init
|
||||||
chaincodeInvoke 1 0 1 0 2
|
chaincodeInvoke 1 $NAME 0 1 0 2
|
||||||
|
|
||||||
# Query chaincode on peer0.org1
|
# Query chaincode on peer0.org1
|
||||||
echo "Querying chaincode on peer0.org1..."
|
echo "Querying chaincode on peer0.org1..."
|
||||||
chaincodeQuery 0 1 100
|
chaincodeQuery 0 1 100 $NAME
|
||||||
|
|
||||||
# Invoke chaincode on peer0.org1 and peer0.org2
|
# Invoke chaincode on peer0.org1 and peer0.org2
|
||||||
echo "Sending invoke transaction on peer0.org1 peer0.org2..."
|
echo "Sending invoke transaction on peer0.org1 peer0.org2..."
|
||||||
chaincodeInvoke 0 0 1 0 2
|
chaincodeInvoke 0 $NAME 0 1 0 2
|
||||||
|
|
||||||
# Query chaincode on peer0.org1
|
# Query chaincode on peer0.org1
|
||||||
echo "Querying chaincode on peer0.org1..."
|
echo "Querying chaincode on peer0.org1..."
|
||||||
chaincodeQuery 0 1 90
|
chaincodeQuery 0 1 90 $NAME
|
||||||
|
|
||||||
## Install chaincode on peer1.org2
|
## Install chaincode on peer1.org2
|
||||||
echo "Installing chaincode on peer1.org2..."
|
echo "Installing chaincode on peer1.org2..."
|
||||||
installChaincode 1 2
|
installChaincode 1 2 $NAME
|
||||||
|
|
||||||
# Query on chaincode on peer1.org2, check if the result is 90
|
# Query on chaincode on peer1.org2, check if the result is 90
|
||||||
echo "Querying chaincode on peer1.org2..."
|
echo "Querying chaincode on peer1.org2..."
|
||||||
chaincodeQuery 1 2 90
|
chaincodeQuery 1 2 90 $NAME
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,13 @@ DELAY="$2"
|
||||||
CC_SRC_LANGUAGE="$3"
|
CC_SRC_LANGUAGE="$3"
|
||||||
TIMEOUT="$4"
|
TIMEOUT="$4"
|
||||||
VERBOSE="$5"
|
VERBOSE="$5"
|
||||||
|
NAME="$6"
|
||||||
: ${CHANNEL_NAME:="mychannel"}
|
: ${CHANNEL_NAME:="mychannel"}
|
||||||
: ${DELAY:="3"}
|
: ${DELAY:="3"}
|
||||||
: ${CC_SRC_LANGUAGE:="go"}
|
: ${CC_SRC_LANGUAGE:="go"}
|
||||||
: ${TIMEOUT:="10"}
|
: ${TIMEOUT:="10"}
|
||||||
: ${VERBOSE:="false"}
|
: ${VERBOSE:="false"}
|
||||||
|
: ${NAME:="mycc"}
|
||||||
CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]`
|
CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]`
|
||||||
COUNTER=1
|
COUNTER=1
|
||||||
MAX_RETRY=5
|
MAX_RETRY=5
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ DELAY="$2"
|
||||||
CC_SRC_LANGUAGE="$3"
|
CC_SRC_LANGUAGE="$3"
|
||||||
TIMEOUT="$4"
|
TIMEOUT="$4"
|
||||||
VERBOSE="$5"
|
VERBOSE="$5"
|
||||||
|
NAME="$6"
|
||||||
: ${CHANNEL_NAME:="mychannel"}
|
: ${CHANNEL_NAME:="mychannel"}
|
||||||
: ${DELAY:="3"}
|
: ${DELAY:="3"}
|
||||||
: ${CC_SRC_LANGUAGE:="go"}
|
: ${CC_SRC_LANGUAGE:="go"}
|
||||||
: ${TIMEOUT:="10"}
|
: ${TIMEOUT:="10"}
|
||||||
: ${VERBOSE:="false"}
|
: ${VERBOSE:="false"}
|
||||||
|
: ${NAME:="mycc"}
|
||||||
CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]`
|
CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]`
|
||||||
COUNTER=1
|
COUNTER=1
|
||||||
MAX_RETRY=5
|
MAX_RETRY=5
|
||||||
|
|
@ -61,23 +63,23 @@ joinChannelWithRetry 1 3
|
||||||
echo "===================== peer1.org3 joined channel '$CHANNEL_NAME' ===================== "
|
echo "===================== peer1.org3 joined channel '$CHANNEL_NAME' ===================== "
|
||||||
|
|
||||||
## at first we package the chaincode
|
## at first we package the chaincode
|
||||||
packageChaincode 1 0 3
|
packageChaincode 1 0 3 $NAME
|
||||||
|
|
||||||
echo "Installing chaincode on peer0.org3..."
|
echo "Installing chaincode on peer0.org3..."
|
||||||
installChaincode 0 3
|
installChaincode 0 3 $NAME
|
||||||
|
|
||||||
## query whether the chaincode is installed
|
## query whether the chaincode is installed
|
||||||
queryInstalled 0 3
|
queryInstalled 0 3
|
||||||
|
|
||||||
## sanity check: expect the chaincode to be already committed
|
## sanity check: expect the chaincode to be already committed
|
||||||
queryCommitted 1 0 3
|
queryCommitted 1 0 3 $NAME
|
||||||
|
|
||||||
## approve it for our org, so that our peers know what package to invoke
|
## approve it for our org, so that our peers know what package to invoke
|
||||||
approveForMyOrg 1 0 3
|
approveForMyOrg 1 0 3 $NAME
|
||||||
|
|
||||||
# Query on chaincode on peer0.org3, check if the result is 90
|
# Query on chaincode on peer0.org3, check if the result is 90
|
||||||
echo "Querying chaincode on peer0.org3..."
|
echo "Querying chaincode on peer0.org3..."
|
||||||
chaincodeQuery 0 3 90
|
chaincodeQuery 0 3 90 $NAME
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "========= Finished adding Org3 to your first network! ========= "
|
echo "========= Finished adding Org3 to your first network! ========= "
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,12 @@ DELAY="$2"
|
||||||
CC_SRC_LANGUAGE="$3"
|
CC_SRC_LANGUAGE="$3"
|
||||||
TIMEOUT="$4"
|
TIMEOUT="$4"
|
||||||
VERBOSE="$5"
|
VERBOSE="$5"
|
||||||
|
NAME="$6"
|
||||||
: ${CHANNEL_NAME:="mychannel"}
|
: ${CHANNEL_NAME:="mychannel"}
|
||||||
: ${TIMEOUT:="10"}
|
: ${TIMEOUT:="10"}
|
||||||
: ${CC_SRC_LANGUAGE:="go"}
|
: ${CC_SRC_LANGUAGE:="go"}
|
||||||
: ${VERBOSE:="false"}
|
: ${VERBOSE:="false"}
|
||||||
|
: ${NAME:="mycc"}
|
||||||
CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]`
|
CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]`
|
||||||
COUNTER=1
|
COUNTER=1
|
||||||
MAX_RETRY=5
|
MAX_RETRY=5
|
||||||
|
|
@ -55,23 +57,23 @@ echo "Channel name : "$CHANNEL_NAME
|
||||||
|
|
||||||
# Query chaincode on peer0.org3, check if the result is 90
|
# Query chaincode on peer0.org3, check if the result is 90
|
||||||
echo "Querying chaincode on peer0.org3..."
|
echo "Querying chaincode on peer0.org3..."
|
||||||
chaincodeQuery 0 3 90
|
chaincodeQuery 0 3 90 $NAME
|
||||||
|
|
||||||
# Invoke chaincode on peer0.org1 and peer0.org3
|
# Invoke chaincode on peer0.org1 and peer0.org3
|
||||||
echo "Sending invoke transaction on peer0.org1 peer0.org3..."
|
echo "Sending invoke transaction on peer0.org1 peer0.org3..."
|
||||||
chaincodeInvoke 0 0 1 0 3
|
chaincodeInvoke 0 $NAME 0 1 0 3
|
||||||
|
|
||||||
# Query on chaincode on peer0.org3, peer0.org2, peer0.org1 check if the result is 80
|
# Query on chaincode on peer0.org3, peer0.org2, peer0.org1 check if the result is 80
|
||||||
# We query a peer in each organization, to ensure peers from all organizations are in sync
|
# We query a peer in each organization, to ensure peers from all organizations are in sync
|
||||||
# and there is no state fork between organizations.
|
# and there is no state fork between organizations.
|
||||||
echo "Querying chaincode on peer0.org3..."
|
echo "Querying chaincode on peer0.org3..."
|
||||||
chaincodeQuery 0 3 80
|
chaincodeQuery 0 3 80 $NAME
|
||||||
|
|
||||||
echo "Querying chaincode on peer0.org2..."
|
echo "Querying chaincode on peer0.org2..."
|
||||||
chaincodeQuery 0 2 80
|
chaincodeQuery 0 2 80 $NAME
|
||||||
|
|
||||||
echo "Querying chaincode on peer0.org1..."
|
echo "Querying chaincode on peer0.org1..."
|
||||||
chaincodeQuery 0 1 80
|
chaincodeQuery 0 1 80 $NAME
|
||||||
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,13 @@ DELAY="$2"
|
||||||
CC_SRC_LANGUAGE="$3"
|
CC_SRC_LANGUAGE="$3"
|
||||||
TIMEOUT="$4"
|
TIMEOUT="$4"
|
||||||
VERBOSE="$5"
|
VERBOSE="$5"
|
||||||
|
NAME="$6"
|
||||||
: ${CHANNEL_NAME:="mychannel"}
|
: ${CHANNEL_NAME:="mychannel"}
|
||||||
: ${DELAY:="5"}
|
: ${DELAY:="5"}
|
||||||
: ${CC_SRC_LANGUAGE:="go"}
|
: ${CC_SRC_LANGUAGE:="go"}
|
||||||
: ${TIMEOUT:="10"}
|
: ${TIMEOUT:="10"}
|
||||||
: ${VERBOSE:="false"}
|
: ${VERBOSE:="false"}
|
||||||
|
: ${NAME:="mycc"}
|
||||||
CC_SRC_LANGUAGE=$(echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:])
|
CC_SRC_LANGUAGE=$(echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:])
|
||||||
COUNTER=1
|
COUNTER=1
|
||||||
MAX_RETRY=5
|
MAX_RETRY=5
|
||||||
|
|
@ -47,19 +49,19 @@ sleep $DELAY
|
||||||
|
|
||||||
#Query on chaincode on Peer0/Org1
|
#Query on chaincode on Peer0/Org1
|
||||||
echo "Querying chaincode on org1/peer0..."
|
echo "Querying chaincode on org1/peer0..."
|
||||||
chaincodeQuery 0 1 90
|
chaincodeQuery 0 1 90 $NAME
|
||||||
|
|
||||||
sleep $DELAY
|
sleep $DELAY
|
||||||
|
|
||||||
#Invoke on chaincode on Peer0/Org1
|
#Invoke on chaincode on Peer0/Org1
|
||||||
echo "Sending invoke transaction on org1/peer0..."
|
echo "Sending invoke transaction on org1/peer0..."
|
||||||
chaincodeInvoke 0 1 0 2
|
chaincodeInvoke 0 $NAME 1 0 2
|
||||||
|
|
||||||
sleep $DELAY
|
sleep $DELAY
|
||||||
|
|
||||||
#Query on chaincode on Peer0/Org1
|
#Query on chaincode on Peer0/Org1
|
||||||
echo "Querying chaincode on org1/peer0..."
|
echo "Querying chaincode on org1/peer0..."
|
||||||
chaincodeQuery 0 1 80
|
chaincodeQuery 0 1 80 $NAME
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "===================== All GOOD, End-2-End UPGRADE Scenario execution completed ===================== "
|
echo "===================== All GOOD, End-2-End UPGRADE Scenario execution completed ===================== "
|
||||||
|
|
|
||||||
|
|
@ -118,9 +118,10 @@ packageChaincode() {
|
||||||
VERSION=$1
|
VERSION=$1
|
||||||
PEER=$2
|
PEER=$2
|
||||||
ORG=$3
|
ORG=$3
|
||||||
|
NAME=$4
|
||||||
setGlobals $PEER $ORG
|
setGlobals $PEER $ORG
|
||||||
set -x
|
set -x
|
||||||
peer lifecycle chaincode package mycc.tar.gz --path ${CC_SRC_PATH} --lang ${CC_RUNTIME_LANGUAGE} --label mycc_${VERSION} >&log.txt
|
peer lifecycle chaincode package $NAME.tar.gz --path ${CC_SRC_PATH} --lang ${CC_RUNTIME_LANGUAGE} --label $NAME_${VERSION} >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
cat log.txt
|
cat log.txt
|
||||||
|
|
@ -133,9 +134,10 @@ packageChaincode() {
|
||||||
installChaincode() {
|
installChaincode() {
|
||||||
PEER=$1
|
PEER=$1
|
||||||
ORG=$2
|
ORG=$2
|
||||||
|
NAME=$3
|
||||||
setGlobals $PEER $ORG
|
setGlobals $PEER $ORG
|
||||||
set -x
|
set -x
|
||||||
peer lifecycle chaincode install mycc.tar.gz >&log.txt
|
peer lifecycle chaincode install $NAME.tar.gz >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
cat log.txt
|
cat log.txt
|
||||||
|
|
@ -166,15 +168,18 @@ approveForMyOrg() {
|
||||||
VERSION=$1
|
VERSION=$1
|
||||||
PEER=$2
|
PEER=$2
|
||||||
ORG=$3
|
ORG=$3
|
||||||
|
NAME=$4
|
||||||
setGlobals $PEER $ORG
|
setGlobals $PEER $ORG
|
||||||
|
|
||||||
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
|
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
|
||||||
set -x
|
set -x
|
||||||
peer lifecycle chaincode approveformyorg --channelID $CHANNEL_NAME --name mycc --version ${VERSION} --init-required --package-id ${PACKAGE_ID} --sequence ${VERSION} --waitForEvent >&log.txt
|
peer lifecycle chaincode approveformyorg --channelID $CHANNEL_NAME --name $NAME --version ${VERSION} --init-required --package-id ${PACKAGE_ID} --sequence ${VERSION} --waitForEvent >&log.txt
|
||||||
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
else
|
else
|
||||||
set -x
|
set -x
|
||||||
peer lifecycle chaincode approveformyorg --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name mycc --version ${VERSION} --init-required --package-id ${PACKAGE_ID} --sequence ${VERSION} --waitForEvent >&log.txt
|
peer lifecycle chaincode approveformyorg --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name $NAME --version ${VERSION} --init-required --package-id ${PACKAGE_ID} --sequence ${VERSION} --waitForEvent >&log.txt
|
||||||
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
fi
|
fi
|
||||||
cat log.txt
|
cat log.txt
|
||||||
|
|
@ -187,6 +192,8 @@ approveForMyOrg() {
|
||||||
commitChaincodeDefinition() {
|
commitChaincodeDefinition() {
|
||||||
VERSION=$1
|
VERSION=$1
|
||||||
shift
|
shift
|
||||||
|
NAME=$1
|
||||||
|
shift
|
||||||
parsePeerConnectionParameters $@
|
parsePeerConnectionParameters $@
|
||||||
res=$?
|
res=$?
|
||||||
verifyResult $res "Invoke transaction failed on channel '$CHANNEL_NAME' due to uneven number of peer and org parameters "
|
verifyResult $res "Invoke transaction failed on channel '$CHANNEL_NAME' due to uneven number of peer and org parameters "
|
||||||
|
|
@ -196,12 +203,12 @@ commitChaincodeDefinition() {
|
||||||
# it using the "-o" option
|
# it using the "-o" option
|
||||||
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
|
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
|
||||||
set -x
|
set -x
|
||||||
peer lifecycle chaincode commit -o orderer.example.com:7050 --channelID $CHANNEL_NAME --name mycc $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --init-required >&log.txt
|
peer lifecycle chaincode commit -o orderer.example.com:7050 --channelID $CHANNEL_NAME --name $NAME $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --init-required >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
else
|
else
|
||||||
set -x
|
set -x
|
||||||
peer lifecycle chaincode commit -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name mycc $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --init-required >&log.txt
|
peer lifecycle chaincode commit -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name $NAME $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --init-required >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
fi
|
fi
|
||||||
|
|
@ -216,7 +223,8 @@ checkCommitReadiness() {
|
||||||
VERSION=$1
|
VERSION=$1
|
||||||
PEER=$2
|
PEER=$2
|
||||||
ORG=$3
|
ORG=$3
|
||||||
shift 3
|
NAME=$4
|
||||||
|
shift 4
|
||||||
setGlobals $PEER $ORG
|
setGlobals $PEER $ORG
|
||||||
echo "===================== Checking the commit readiness of the chaincode definition on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'... ===================== "
|
echo "===================== Checking the commit readiness of the chaincode definition on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'... ===================== "
|
||||||
local rc=1
|
local rc=1
|
||||||
|
|
@ -230,7 +238,7 @@ checkCommitReadiness() {
|
||||||
sleep $DELAY
|
sleep $DELAY
|
||||||
echo "Attempting to check the commit readiness of the chaincode definition on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
|
echo "Attempting to check the commit readiness of the chaincode definition on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
|
||||||
set -x
|
set -x
|
||||||
peer lifecycle chaincode checkcommitreadiness --channelID $CHANNEL_NAME --name mycc $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --output json --init-required >&log.txt
|
peer lifecycle chaincode checkcommitreadiness --channelID $CHANNEL_NAME --name $NAME $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --output json --init-required >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
test $res -eq 0 || continue
|
test $res -eq 0 || continue
|
||||||
|
|
@ -257,6 +265,7 @@ queryCommitted() {
|
||||||
VERSION=$1
|
VERSION=$1
|
||||||
PEER=$2
|
PEER=$2
|
||||||
ORG=$3
|
ORG=$3
|
||||||
|
NAME=$4
|
||||||
setGlobals $PEER $ORG
|
setGlobals $PEER $ORG
|
||||||
EXPECTED_RESULT="Version: ${VERSION}, Sequence: ${VERSION}, Endorsement Plugin: escc, Validation Plugin: vscc"
|
EXPECTED_RESULT="Version: ${VERSION}, Sequence: ${VERSION}, Endorsement Plugin: escc, Validation Plugin: vscc"
|
||||||
echo "===================== Querying chaincode definition on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'... ===================== "
|
echo "===================== Querying chaincode definition on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'... ===================== "
|
||||||
|
|
@ -271,7 +280,7 @@ queryCommitted() {
|
||||||
sleep $DELAY
|
sleep $DELAY
|
||||||
echo "Attempting to Query committed status on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
|
echo "Attempting to Query committed status on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
|
||||||
set -x
|
set -x
|
||||||
peer lifecycle chaincode querycommitted --channelID $CHANNEL_NAME --name mycc >&log.txt
|
peer lifecycle chaincode querycommitted --channelID $CHANNEL_NAME --name $NAME >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
test $res -eq 0 && VALUE=$(cat log.txt | grep -o '^Version: [0-9], Sequence: [0-9], Endorsement Plugin: escc, Validation Plugin: vscc')
|
test $res -eq 0 && VALUE=$(cat log.txt | grep -o '^Version: [0-9], Sequence: [0-9], Endorsement Plugin: escc, Validation Plugin: vscc')
|
||||||
|
|
@ -294,6 +303,7 @@ chaincodeQuery() {
|
||||||
ORG=$2
|
ORG=$2
|
||||||
setGlobals $PEER $ORG
|
setGlobals $PEER $ORG
|
||||||
EXPECTED_RESULT=$3
|
EXPECTED_RESULT=$3
|
||||||
|
NAME=$4
|
||||||
echo "===================== Querying on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'... ===================== "
|
echo "===================== Querying on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'... ===================== "
|
||||||
local rc=1
|
local rc=1
|
||||||
local starttime=$(date +%s)
|
local starttime=$(date +%s)
|
||||||
|
|
@ -306,7 +316,7 @@ chaincodeQuery() {
|
||||||
sleep $DELAY
|
sleep $DELAY
|
||||||
echo "Attempting to Query peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
|
echo "Attempting to Query peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
|
||||||
set -x
|
set -x
|
||||||
peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}' >&log.txt
|
peer chaincode query -C $CHANNEL_NAME -n $NAME -c '{"Args":["query","a"]}' >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
test $res -eq 0 && VALUE=$(cat log.txt | awk '/Query Result/ {print $NF}')
|
test $res -eq 0 && VALUE=$(cat log.txt | awk '/Query Result/ {print $NF}')
|
||||||
|
|
@ -418,6 +428,8 @@ parsePeerConnectionParameters() {
|
||||||
chaincodeInvoke() {
|
chaincodeInvoke() {
|
||||||
IS_INIT=$1
|
IS_INIT=$1
|
||||||
shift
|
shift
|
||||||
|
NAME=$1
|
||||||
|
shift
|
||||||
parsePeerConnectionParameters $@
|
parsePeerConnectionParameters $@
|
||||||
res=$?
|
res=$?
|
||||||
verifyResult $res "Invoke transaction failed on channel '$CHANNEL_NAME' due to uneven number of peer and org parameters "
|
verifyResult $res "Invoke transaction failed on channel '$CHANNEL_NAME' due to uneven number of peer and org parameters "
|
||||||
|
|
@ -435,12 +447,12 @@ chaincodeInvoke() {
|
||||||
# it using the "-o" option
|
# it using the "-o" option
|
||||||
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
|
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
|
||||||
set -x
|
set -x
|
||||||
peer chaincode invoke -o orderer.example.com:7050 -C $CHANNEL_NAME -n mycc $PEER_CONN_PARMS ${INIT_ARG} -c ${CCARGS} >&log.txt
|
peer chaincode invoke -o orderer.example.com:7050 -C $CHANNEL_NAME -n $NAME $PEER_CONN_PARMS ${INIT_ARG} -c ${CCARGS} >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
else
|
else
|
||||||
set -x
|
set -x
|
||||||
peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc $PEER_CONN_PARMS ${INIT_ARG} -c ${CCARGS} >&log.txt
|
peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n $NAME $PEER_CONN_PARMS ${INIT_ARG} -c ${CCARGS} >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue