Merge "[FAB-7527] Improves BYFN"

This commit is contained in:
Gari Singh 2018-02-08 18:02:02 +00:00 committed by Gerrit Code Review
commit b24a7c7f2d
4 changed files with 112 additions and 95 deletions

View file

@ -1,5 +1,4 @@
#!/bin/bash #!/bin/bash
# #
# Copyright IBM Corp All Rights Reserved # Copyright IBM Corp All Rights Reserved
# #
@ -35,15 +34,15 @@ export FABRIC_CFG_PATH=${PWD}
# Print the usage message # Print the usage message
function printHelp () { function printHelp () {
echo "Usage: " echo "Usage: "
echo " byfn.sh -m up|down|restart|generate [-c <channel name>] [-t <timeout>] [-d <delay>] [-f <docker-compose-file>] [-s <dbtype>]" echo " byfn.sh up|down|restart|generate [-c <channel name>] [-t <timeout>] [-d <delay>] [-f <docker-compose-file>] [-s <dbtype>]"
echo " byfn.sh -h|--help (print this message)" echo " byfn.sh -h|--help (print this message)"
echo " -m <mode> - one of 'up', 'down', 'restart' or 'generate'" echo " <mode> - one of 'up', 'down', 'restart' or 'generate'"
echo " - 'up' - bring up the network with docker-compose up" echo " - 'up' - bring up the network with docker-compose up"
echo " - 'down' - clear the network with docker-compose down" echo " - 'down' - clear the network with docker-compose down"
echo " - 'restart' - restart the network" echo " - 'restart' - restart the network"
echo " - 'generate' - generate required certificates and genesis block" echo " - 'generate' - generate required certificates and genesis block"
echo " -c <channel name> - channel name to use (defaults to \"mychannel\")" echo " -c <channel name> - channel name to use (defaults to \"mychannel\")"
echo " -t <timeout> - CLI timeout duration in seconds (defaults to 10000)" echo " -t <timeout> - CLI timeout duration in seconds (defaults to 10)"
echo " -d <delay> - delay duration in seconds (defaults to 3)" echo " -d <delay> - delay duration in seconds (defaults to 3)"
echo " -f <docker-compose-file> - specify which docker-compose file use (defaults to docker-compose-cli.yaml)" echo " -f <docker-compose-file> - specify which docker-compose file use (defaults to docker-compose-cli.yaml)"
echo " -s <dbtype> - the database backend to use: goleveldb (default) or couchdb" echo " -s <dbtype> - the database backend to use: goleveldb (default) or couchdb"
@ -52,22 +51,22 @@ function printHelp () {
echo "Typically, one would first generate the required certificates and " echo "Typically, one would first generate the required certificates and "
echo "genesis block, then bring up the network. e.g.:" echo "genesis block, then bring up the network. e.g.:"
echo echo
echo " byfn.sh -m generate -c mychannel" echo " byfn.sh generate -c mychannel"
echo " byfn.sh -m up -c mychannel -s couchdb" echo " byfn.sh up -c mychannel -s couchdb"
echo " byfn.sh -m up -l node" echo " byfn.sh up -l node"
echo " byfn.sh -m down -c mychannel" echo " byfn.sh down -c mychannel"
echo echo
echo "Taking all defaults:" echo "Taking all defaults:"
echo " byfn.sh -m generate" echo " byfn.sh generate"
echo " byfn.sh -m up" echo " byfn.sh up"
echo " byfn.sh -m down" echo " byfn.sh down"
} }
# Ask user for confirmation to proceed # Ask user for confirmation to proceed
function askProceed () { function askProceed () {
read -p "Continue (y/n)? " ans read -p "Continue? [Y/n] " ans
case "$ans" in case "$ans" in
y|Y ) y|Y|"" )
echo "proceeding ..." echo "proceeding ..."
;; ;;
n|N ) n|N )
@ -113,16 +112,20 @@ function networkUp () {
generateChannelArtifacts generateChannelArtifacts
fi fi
if [ "${IF_COUCHDB}" == "couchdb" ]; then if [ "${IF_COUCHDB}" == "couchdb" ]; then
CHANNEL_NAME=$CHANNEL_NAME TIMEOUT=$CLI_TIMEOUT DELAY=$CLI_DELAY LANG=$LANGUAGE docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH up -d 2>&1 docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH up -d 2>&1
else else
CHANNEL_NAME=$CHANNEL_NAME TIMEOUT=$CLI_TIMEOUT DELAY=$CLI_DELAY LANG=$LANGUAGE docker-compose -f $COMPOSE_FILE up -d 2>&1 docker-compose -f $COMPOSE_FILE up -d 2>&1
fi fi
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "ERROR !!!! Unable to start network" echo "ERROR !!!! Unable to start network"
docker logs -f cli
exit 1 exit 1
fi fi
docker logs -f cli # now run the end to end script
docker exec cli scripts/script.sh $CHANNEL_NAME $CLI_DELAY $LANGUAGE $CLI_TIMEOUT
if [ $? -ne 0 ]; then
echo "ERROR !!!! Test failed"
exit 1
fi
} }
# Tear down running network # Tear down running network
@ -309,7 +312,7 @@ OS_ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/window
# timeout duration - the duration the CLI should wait for a response from # timeout duration - the duration the CLI should wait for a response from
# another container before giving up # another container before giving up
CLI_TIMEOUT=10 CLI_TIMEOUT=10
#default for delay # default for delay between commands
CLI_DELAY=3 CLI_DELAY=3
# channel name defaults to "mychannel" # channel name defaults to "mychannel"
CHANNEL_NAME="mychannel" CHANNEL_NAME="mychannel"
@ -320,14 +323,30 @@ COMPOSE_FILE_COUCH=docker-compose-couch.yaml
# use golang as the default language for chaincode # use golang as the default language for chaincode
LANGUAGE=golang LANGUAGE=golang
# Parse commandline args # Parse commandline args
while getopts "h?m:c:t:d:f:s:l:" opt; do if [ "$1" = "-m" ];then # supports old usage, muscle memory is powerful!
shift
fi
MODE=$1;shift
# Determine whether starting, stopping, restarting or generating for announce
if [ "$MODE" == "up" ]; then
EXPMODE="Starting"
elif [ "$MODE" == "down" ]; then
EXPMODE="Stopping"
elif [ "$MODE" == "restart" ]; then
EXPMODE="Restarting"
elif [ "$MODE" == "generate" ]; then
EXPMODE="Generating certs and genesis block for"
else
printHelp
exit 1
fi
while getopts "h?c:t:d:f:s:l:a?" opt; do
case "$opt" in case "$opt" in
h|\?) h|\?)
printHelp printHelp
exit 0 exit 0
;; ;;
m) MODE=$OPTARG
;;
c) CHANNEL_NAME=$OPTARG c) CHANNEL_NAME=$OPTARG
;; ;;
t) CLI_TIMEOUT=$OPTARG t) CLI_TIMEOUT=$OPTARG
@ -343,20 +362,6 @@ while getopts "h?m:c:t:d:f:s:l:" opt; do
esac esac
done done
# Determine whether starting, stopping, restarting or generating for announce
if [ "$MODE" == "up" ]; then
EXPMODE="Starting"
elif [ "$MODE" == "down" ]; then
EXPMODE="Stopping"
elif [ "$MODE" == "restart" ]; then
EXPMODE="Restarting"
elif [ "$MODE" == "generate" ]; then
EXPMODE="Generating certs and genesis block for"
else
printHelp
exit 1
fi
# Announce what was requested # Announce what was requested
if [ "${IF_COUCHDB}" == "couchdb" ]; then if [ "${IF_COUCHDB}" == "couchdb" ]; then
@ -371,13 +376,13 @@ askProceed
#Create the network using docker compose #Create the network using docker compose
if [ "${MODE}" == "up" ]; then if [ "${MODE}" == "up" ]; then
networkUp networkUp
elif [ "${MODE}" == "down" ]; then ## Clear the network elif [ "${MODE}" == "down" ]; then ## Clear the network
networkDown networkDown
elif [ "${MODE}" == "generate" ]; then ## Generate Artifacts elif [ "${MODE}" == "generate" ]; then ## Generate Artifacts
generateCerts generateCerts
replacePrivateKey replacePrivateKey
generateChannelArtifacts generateChannelArtifacts
elif [ "${MODE}" == "restart" ]; then ## Restart the network elif [ "${MODE}" == "restart" ]; then ## Restart the network
networkDown networkDown
networkUp networkUp
else else

View file

@ -67,7 +67,7 @@ services:
- CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: /bin/bash -c './scripts/script.sh ${CHANNEL_NAME} ${DELAY} ${LANG}; sleep $TIMEOUT' command: /bin/bash -c 'sleep 1000'
volumes: volumes:
- /var/run/:/host/var/run/ - /var/run/:/host/var/run/
- ./../chaincode/:/opt/gopath/src/github.com/chaincode - ./../chaincode/:/opt/gopath/src/github.com/chaincode

View file

@ -70,7 +70,7 @@ services:
- CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: /bin/bash -c 'sleep 10000' command: /bin/bash -c 'sleep 1000'
volumes: volumes:
- /var/run/:/host/var/run/ - /var/run/:/host/var/run/
- ./../chaincode/:/opt/gopath/src/github.com/chaincode - ./../chaincode/:/opt/gopath/src/github.com/chaincode

View file

@ -13,7 +13,7 @@ CHANNEL_NAME="$1"
DELAY="$2" DELAY="$2"
LANGUAGE="$3" LANGUAGE="$3"
: ${CHANNEL_NAME:="mychannel"} : ${CHANNEL_NAME:="mychannel"}
: ${TIMEOUT:="60"} : ${TIMEOUT:="10"}
: ${LANGUAGE:="golang"} : ${LANGUAGE:="golang"}
LANGUAGE=`echo "$LANGUAGE" | tr [:upper:] [:lower:]` LANGUAGE=`echo "$LANGUAGE" | tr [:upper:] [:lower:]`
COUNTER=1 COUNTER=1
@ -38,21 +38,22 @@ verifyResult () {
} }
setGlobals () { setGlobals () {
PEER=$1
if [ $1 -eq 0 -o $1 -eq 1 ] ; then ORG=$2
if [ $ORG -eq 1 ] ; then
CORE_PEER_LOCALMSPID="Org1MSP" CORE_PEER_LOCALMSPID="Org1MSP"
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
if [ $1 -eq 0 ]; then if [ $PEER -eq 0 ]; then
CORE_PEER_ADDRESS=peer0.org1.example.com:7051 CORE_PEER_ADDRESS=peer0.org1.example.com:7051
else else
CORE_PEER_ADDRESS=peer1.org1.example.com:7051 CORE_PEER_ADDRESS=peer1.org1.example.com:7051
fi fi
else elif [ $ORG -eq 2 ] ; then
CORE_PEER_LOCALMSPID="Org2MSP" CORE_PEER_LOCALMSPID="Org2MSP"
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
if [ $1 -eq 2 ]; then if [ $PEER -eq 0 ]; then
CORE_PEER_ADDRESS=peer0.org2.example.com:7051 CORE_PEER_ADDRESS=peer0.org2.example.com:7051
else else
CORE_PEER_ADDRESS=peer1.org2.example.com:7051 CORE_PEER_ADDRESS=peer1.org2.example.com:7051
@ -63,9 +64,9 @@ setGlobals () {
} }
createChannel() { createChannel() {
setGlobals 0 setGlobals 0 0
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
peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx >&log.txt peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx >&log.txt
else else
peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt
@ -79,13 +80,14 @@ createChannel() {
updateAnchorPeers() { updateAnchorPeers() {
PEER=$1 PEER=$1
setGlobals $PEER ORG=$2
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
peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx >&log.txt peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx >&log.txt
else else
peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt
fi fi
res=$? res=$?
cat log.txt cat log.txt
verifyResult $res "Anchor peer update failed" verifyResult $res "Anchor peer update failed"
@ -96,44 +98,51 @@ updateAnchorPeers() {
## Sometimes Join takes time hence RETRY at least for 5 times ## Sometimes Join takes time hence RETRY at least for 5 times
joinWithRetry () { joinWithRetry () {
PEER=$1
ORG=$2
peer channel join -b $CHANNEL_NAME.block >&log.txt peer channel join -b $CHANNEL_NAME.block >&log.txt
res=$? res=$?
cat log.txt cat log.txt
if [ $res -ne 0 -a $COUNTER -lt $MAX_RETRY ]; then if [ $res -ne 0 -a $COUNTER -lt $MAX_RETRY ]; then
COUNTER=` expr $COUNTER + 1` COUNTER=` expr $COUNTER + 1`
echo "PEER$1 failed to join the channel, Retry after 2 seconds" echo "peer${PEER}.org${ORG} failed to join the channel, Retry after $DELAY seconds"
sleep $DELAY sleep $DELAY
joinWithRetry $1 joinWithRetry $PEER $ORG
else else
COUNTER=1 COUNTER=1
fi fi
verifyResult $res "After $MAX_RETRY attempts, PEER$ch has failed to Join the Channel" verifyResult $res "After $MAX_RETRY attempts, peer${PEER}.org${ORG} has failed to Join the Channel"
} }
joinChannel () { joinChannel () {
for ch in 0 1 2 3; do for org in 1 2; do
setGlobals $ch for peer in 0 1; do
joinWithRetry $ch setGlobals $peer $org
echo "===================== PEER$ch joined on the channel \"$CHANNEL_NAME\" ===================== " joinWithRetry $peer $org
echo "===================== peer${peer}.org${org} joined on the channel \"$CHANNEL_NAME\" ===================== "
sleep $DELAY sleep $DELAY
echo echo
done
done done
} }
installChaincode () { installChaincode () {
PEER=$1 PEER=$1
setGlobals $PEER ORG=$2
setGlobals $PEER $ORG
peer chaincode install -n mycc -v 1.0 -l ${LANGUAGE} -p ${CC_SRC_PATH} >&log.txt peer chaincode install -n mycc -v 1.0 -l ${LANGUAGE} -p ${CC_SRC_PATH} >&log.txt
res=$? res=$?
cat log.txt cat log.txt
verifyResult $res "Chaincode installation on remote peer PEER$PEER has Failed" verifyResult $res "Chaincode installation on peer${PEER}.org${ORG} has Failed"
echo "===================== Chaincode is installed on remote peer PEER$PEER ===================== " echo "===================== Chaincode is installed on peer${PEER}.org${ORG} ===================== "
echo echo
} }
instantiateChaincode () { instantiateChaincode () {
PEER=$1 PEER=$1
setGlobals $PEER ORG=$2
setGlobals $PEER $ORG
# while 'peer chaincode' command can get the orderer endpoint from the peer (if join was successful), # while 'peer chaincode' command can get the orderer endpoint from the peer (if join was successful),
# lets supply it directly as we know it using the "-o" option # lets supply it directly as we know 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
@ -143,15 +152,17 @@ instantiateChaincode () {
fi fi
res=$? res=$?
cat log.txt cat log.txt
verifyResult $res "Chaincode instantiation on PEER$PEER on channel '$CHANNEL_NAME' failed" verifyResult $res "Chaincode instantiation on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' failed"
echo "===================== Chaincode Instantiation on PEER$PEER on channel '$CHANNEL_NAME' is successful ===================== " echo "===================== Chaincode Instantiation on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' is successful ===================== "
echo echo
} }
chaincodeQuery () { chaincodeQuery () {
PEER=$1 PEER=$1
echo "===================== Querying on PEER$PEER on channel '$CHANNEL_NAME'... ===================== " ORG=$2
setGlobals $PEER setGlobals $PEER $ORG
EXPECTED_RESULT=$3
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)
@ -160,17 +171,17 @@ chaincodeQuery () {
while test "$(($(date +%s)-starttime))" -lt "$TIMEOUT" -a $rc -ne 0 while test "$(($(date +%s)-starttime))" -lt "$TIMEOUT" -a $rc -ne 0
do do
sleep $DELAY sleep $DELAY
echo "Attempting to Query PEER$PEER ...$(($(date +%s)-starttime)) secs" echo "Attempting to Query peer${PEER}.org${ORG} ...$(($(date +%s)-starttime)) secs"
peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}' >&log.txt peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}' >&log.txt
test $? -eq 0 && VALUE=$(cat log.txt | awk '/Query Result/ {print $NF}') test $? -eq 0 && VALUE=$(cat log.txt | awk '/Query Result/ {print $NF}')
test "$VALUE" = "$2" && let rc=0 test "$VALUE" = "$EXPECTED_RESULT" && let rc=0
done done
echo echo
cat log.txt cat log.txt
if test $rc -eq 0 ; then if test $rc -eq 0 ; then
echo "===================== Query on PEER$PEER on channel '$CHANNEL_NAME' is successful ===================== " echo "===================== Query on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' is successful ===================== "
else else
echo "!!!!!!!!!!!!!!! Query result on PEER$PEER is INVALID !!!!!!!!!!!!!!!!" echo "!!!!!!!!!!!!!!! Query result on peer${PEER}.org${ORG} is INVALID !!!!!!!!!!!!!!!!"
echo "================== ERROR !!! FAILED to execute End-2-End Scenario ==================" echo "================== ERROR !!! FAILED to execute End-2-End Scenario =================="
echo echo
exit 1 exit 1
@ -179,7 +190,8 @@ chaincodeQuery () {
chaincodeInvoke () { chaincodeInvoke () {
PEER=$1 PEER=$1
setGlobals $PEER ORG=$2
setGlobals $PEER $ORG
# while 'peer chaincode' command can get the orderer endpoint from the peer (if join was successful), # while 'peer chaincode' command can get the orderer endpoint from the peer (if join was successful),
# lets supply it directly as we know it using the "-o" option # lets supply it directly as we know 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
@ -189,8 +201,8 @@ chaincodeInvoke () {
fi fi
res=$? res=$?
cat log.txt cat log.txt
verifyResult $res "Invoke execution on PEER$PEER failed " verifyResult $res "Invoke execution on peer${PEER}.org${ORG} failed "
echo "===================== Invoke transaction on PEER$PEER on channel '$CHANNEL_NAME' is successful ===================== " echo "===================== Invoke transaction on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' is successful ===================== "
echo echo
} }
@ -204,35 +216,35 @@ joinChannel
## Set the anchor peers for each org in the channel ## Set the anchor peers for each org in the channel
echo "Updating anchor peers for org1..." echo "Updating anchor peers for org1..."
updateAnchorPeers 0 updateAnchorPeers 0 1
echo "Updating anchor peers for org2..." echo "Updating anchor peers for org2..."
updateAnchorPeers 2 updateAnchorPeers 0 2
## Install chaincode on Peer0/Org1 and Peer2/Org2 ## Install chaincode on peer0.org1 and peer0.org2
echo "Installing chaincode on org1/peer0..." echo "Installing chaincode on peer0.org1..."
installChaincode 0 installChaincode 0 1
echo "Install chaincode on org2/peer2..." echo "Install chaincode on peer0.org2..."
installChaincode 2 installChaincode 0 2
#Instantiate chaincode on Peer2/Org2 # Instantiate chaincode on peer0.org2
echo "Instantiating chaincode on org2/peer2..." echo "Instantiating chaincode on peer0.org2..."
instantiateChaincode 2 instantiateChaincode 0 2
#Query on chaincode on Peer0/Org1 # Query chaincode on peer0.org1
echo "Querying chaincode on org1/peer0..." echo "Querying chaincode on peer0.org1..."
chaincodeQuery 0 100 chaincodeQuery 0 1 100
#Invoke on chaincode on Peer0/Org1 # Invoke chaincode on peer0.org1
echo "Sending invoke transaction on org1/peer0..." echo "Sending invoke transaction on peer0.org1..."
chaincodeInvoke 0 chaincodeInvoke 0 1
## Install chaincode on Peer3/Org2 ## Install chaincode on peer1.org2
echo "Installing chaincode on org2/peer3..." echo "Installing chaincode on peer1.org2..."
installChaincode 3 installChaincode 1 2
#Query on chaincode on Peer3/Org2, check if the result is 90 # Query on chaincode on peer1.org2, check if the result is 90
echo "Querying chaincode on org2/peer3..." echo "Querying chaincode on peer1.org2..."
chaincodeQuery 3 90 chaincodeQuery 1 2 90
echo echo
echo "========= All GOOD, BYFN execution completed =========== " echo "========= All GOOD, BYFN execution completed =========== "