From dc4de2aee8adfeedc15beb87ebba4e468b0ee404 Mon Sep 17 00:00:00 2001 From: Anoop Vijayan Maniankara Date: Sun, 9 Feb 2020 19:24:44 +0200 Subject: [PATCH] first-network/scripts/*: Make Chaincode name configurable Signed-off-by: Anoop Vijayan Maniankara --- first-network/scripts/script.sh | 3 +++ first-network/scripts/step1org3.sh | 2 ++ first-network/scripts/step2org3.sh | 2 ++ first-network/scripts/testorg3.sh | 2 ++ first-network/scripts/upgrade_to_v14.sh | 2 ++ first-network/scripts/utils.sh | 23 ++++++++++++----------- 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/first-network/scripts/script.sh b/first-network/scripts/script.sh index b9b1b958ba..dc1ad6cfb8 100755 --- a/first-network/scripts/script.sh +++ b/first-network/scripts/script.sh @@ -15,12 +15,14 @@ CC_SRC_LANGUAGE="$3" TIMEOUT="$4" VERBOSE="$5" NO_CHAINCODE="$6" +NAME="$7" : ${CHANNEL_NAME:="mychannel"} : ${DELAY:="3"} : ${CC_SRC_LANGUAGE:="go"} : ${TIMEOUT:="10"} : ${VERBOSE:="false"} : ${NO_CHAINCODE:="false"} +: ${NAME:="mycc"} CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]` COUNTER=1 MAX_RETRY=20 @@ -43,6 +45,7 @@ fi echo "Channel name : "$CHANNEL_NAME +echo "Chaincode name : "$NAME # import utils . scripts/utils.sh diff --git a/first-network/scripts/step1org3.sh b/first-network/scripts/step1org3.sh index 4329860cf6..d8be4e1f4d 100755 --- a/first-network/scripts/step1org3.sh +++ b/first-network/scripts/step1org3.sh @@ -16,11 +16,13 @@ DELAY="$2" CC_SRC_LANGUAGE="$3" TIMEOUT="$4" VERBOSE="$5" +NAME="$6" : ${CHANNEL_NAME:="mychannel"} : ${DELAY:="3"} : ${CC_SRC_LANGUAGE:="go"} : ${TIMEOUT:="10"} : ${VERBOSE:="false"} +: ${NAME:="mycc"} CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]` COUNTER=1 MAX_RETRY=5 diff --git a/first-network/scripts/step2org3.sh b/first-network/scripts/step2org3.sh index fec4dcc427..a9fc3d1535 100755 --- a/first-network/scripts/step2org3.sh +++ b/first-network/scripts/step2org3.sh @@ -19,11 +19,13 @@ DELAY="$2" CC_SRC_LANGUAGE="$3" TIMEOUT="$4" VERBOSE="$5" +NAME="$6" : ${CHANNEL_NAME:="mychannel"} : ${DELAY:="3"} : ${CC_SRC_LANGUAGE:="go"} : ${TIMEOUT:="10"} : ${VERBOSE:="false"} +: ${NAME:="mycc"} CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]` COUNTER=1 MAX_RETRY=5 diff --git a/first-network/scripts/testorg3.sh b/first-network/scripts/testorg3.sh index 04e23114f9..5644bf459c 100755 --- a/first-network/scripts/testorg3.sh +++ b/first-network/scripts/testorg3.sh @@ -25,10 +25,12 @@ DELAY="$2" CC_SRC_LANGUAGE="$3" TIMEOUT="$4" VERBOSE="$5" +NAME="$6" : ${CHANNEL_NAME:="mychannel"} : ${TIMEOUT:="10"} : ${CC_SRC_LANGUAGE:="go"} : ${VERBOSE:="false"} +: ${NAME:="mycc"} CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]` COUNTER=1 MAX_RETRY=5 diff --git a/first-network/scripts/upgrade_to_v14.sh b/first-network/scripts/upgrade_to_v14.sh index 3fb4df685a..154b32e232 100755 --- a/first-network/scripts/upgrade_to_v14.sh +++ b/first-network/scripts/upgrade_to_v14.sh @@ -14,11 +14,13 @@ DELAY="$2" CC_SRC_LANGUAGE="$3" TIMEOUT="$4" VERBOSE="$5" +NAME="$6" : ${CHANNEL_NAME:="mychannel"} : ${DELAY:="5"} : ${CC_SRC_LANGUAGE:="go"} : ${TIMEOUT:="10"} : ${VERBOSE:="false"} +: ${NAME:="mycc"} CC_SRC_LANGUAGE=$(echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]) COUNTER=1 MAX_RETRY=5 diff --git a/first-network/scripts/utils.sh b/first-network/scripts/utils.sh index 8807011849..a4af3c5c76 100755 --- a/first-network/scripts/utils.sh +++ b/first-network/scripts/utils.sh @@ -120,7 +120,7 @@ packageChaincode() { ORG=$3 setGlobals $PEER $ORG 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=$? set +x cat log.txt @@ -133,9 +133,10 @@ packageChaincode() { installChaincode() { PEER=$1 ORG=$2 + NAME=$3 setGlobals $PEER $ORG set -x - peer lifecycle chaincode install mycc.tar.gz >&log.txt + peer lifecycle chaincode install $NAME.tar.gz >&log.txt res=$? set +x cat log.txt @@ -170,11 +171,11 @@ approveForMyOrg() { if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then 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 set +x else 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 set +x fi cat log.txt @@ -196,12 +197,12 @@ commitChaincodeDefinition() { # it using the "-o" option if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then 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=$? set +x else 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=$? set +x fi @@ -230,7 +231,7 @@ checkCommitReadiness() { sleep $DELAY echo "Attempting to check the commit readiness of the chaincode definition on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs" 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=$? set +x test $res -eq 0 || continue @@ -271,7 +272,7 @@ queryCommitted() { sleep $DELAY echo "Attempting to Query committed status on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs" 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=$? set +x test $res -eq 0 && VALUE=$(cat log.txt | grep -o '^Version: [0-9], Sequence: [0-9], Endorsement Plugin: escc, Validation Plugin: vscc') @@ -306,7 +307,7 @@ chaincodeQuery() { sleep $DELAY echo "Attempting to Query peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs" 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=$? set +x test $res -eq 0 && VALUE=$(cat log.txt | awk '/Query Result/ {print $NF}') @@ -435,12 +436,12 @@ chaincodeInvoke() { # it using the "-o" option if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then 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=$? set +x else 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=$? set +x fi