mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-22 17:45:10 +00:00
FAB-8564 add debug commands to byfn
replace DEBUG level logging w/INFO, but add in shell debug statements for all fabric commands for improved UX Change-Id: I97a19db0373ecaf7a504cb95d4815a11cd64dfed Signed-off-by: Christopher Ferris <chrisfer@us.ibm.com>
This commit is contained in:
parent
831e9bfe80
commit
10526d5a1d
12 changed files with 66 additions and 5 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -12,6 +12,9 @@
|
||||||
first-network/channel-artifacts/*.tx
|
first-network/channel-artifacts/*.tx
|
||||||
first-network/channel-artifacts/*.block
|
first-network/channel-artifacts/*.block
|
||||||
first-network/crypto-config/*
|
first-network/crypto-config/*
|
||||||
|
first-network/docker-compose-e2e.yaml
|
||||||
|
first-network/ledgers
|
||||||
|
first-network/ledgers-backup
|
||||||
|
|
||||||
chaincode-docker-devmode/myc.block
|
chaincode-docker-devmode/myc.block
|
||||||
chaincode-docker-devmode/chaincode/sacc/sacc
|
chaincode-docker-devmode/chaincode/sacc/sacc
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ services:
|
||||||
container_name: orderer.example.com
|
container_name: orderer.example.com
|
||||||
image: hyperledger/fabric-orderer:$IMAGE_TAG
|
image: hyperledger/fabric-orderer:$IMAGE_TAG
|
||||||
environment:
|
environment:
|
||||||
- ORDERER_GENERAL_LOGLEVEL=debug
|
- ORDERER_GENERAL_LOGLEVEL=INFO
|
||||||
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
|
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
|
||||||
- ORDERER_GENERAL_GENESISMETHOD=file
|
- ORDERER_GENERAL_GENESISMETHOD=file
|
||||||
- ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
|
- ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ services:
|
||||||
# bridge network as the peers
|
# bridge network as the peers
|
||||||
# https://docs.docker.com/compose/networking/
|
# https://docs.docker.com/compose/networking/
|
||||||
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_byfn
|
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_byfn
|
||||||
#- CORE_LOGGING_LEVEL=ERROR
|
- CORE_LOGGING_LEVEL=INFO
|
||||||
- CORE_LOGGING_LEVEL=DEBUG
|
#- CORE_LOGGING_LEVEL=DEBUG
|
||||||
- CORE_PEER_TLS_ENABLED=true
|
- CORE_PEER_TLS_ENABLED=true
|
||||||
- CORE_PEER_GOSSIP_USELEADERELECTION=true
|
- CORE_PEER_GOSSIP_USELEADERELECTION=true
|
||||||
- CORE_PEER_GOSSIP_ORGLEADER=false
|
- CORE_PEER_GOSSIP_ORGLEADER=false
|
||||||
|
|
|
||||||
|
|
@ -287,7 +287,9 @@ function generateCerts (){
|
||||||
if [ -d "crypto-config" ]; then
|
if [ -d "crypto-config" ]; then
|
||||||
rm -Rf crypto-config
|
rm -Rf crypto-config
|
||||||
fi
|
fi
|
||||||
|
set -x
|
||||||
cryptogen generate --config=./crypto-config.yaml
|
cryptogen generate --config=./crypto-config.yaml
|
||||||
|
set +x
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
echo "Failed to generate certificates..."
|
echo "Failed to generate certificates..."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -345,7 +347,9 @@ function generateChannelArtifacts() {
|
||||||
echo "##########################################################"
|
echo "##########################################################"
|
||||||
# Note: For some unknown reason (at least for now) the block file can't be
|
# Note: For some unknown reason (at least for now) the block file can't be
|
||||||
# named orderer.genesis.block or the orderer will fail to launch!
|
# named orderer.genesis.block or the orderer will fail to launch!
|
||||||
|
set -x
|
||||||
configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
|
configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
|
||||||
|
set +x
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
echo "Failed to generate orderer genesis block..."
|
echo "Failed to generate orderer genesis block..."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -354,7 +358,9 @@ function generateChannelArtifacts() {
|
||||||
echo "#################################################################"
|
echo "#################################################################"
|
||||||
echo "### Generating channel configuration transaction 'channel.tx' ###"
|
echo "### Generating channel configuration transaction 'channel.tx' ###"
|
||||||
echo "#################################################################"
|
echo "#################################################################"
|
||||||
|
set -x
|
||||||
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
|
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
|
||||||
|
set +x
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
echo "Failed to generate channel configuration transaction..."
|
echo "Failed to generate channel configuration transaction..."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -364,7 +370,9 @@ function generateChannelArtifacts() {
|
||||||
echo "#################################################################"
|
echo "#################################################################"
|
||||||
echo "####### Generating anchor peer update for Org1MSP ##########"
|
echo "####### Generating anchor peer update for Org1MSP ##########"
|
||||||
echo "#################################################################"
|
echo "#################################################################"
|
||||||
|
set -x
|
||||||
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP
|
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP
|
||||||
|
set +x
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
echo "Failed to generate anchor peer update for Org1MSP..."
|
echo "Failed to generate anchor peer update for Org1MSP..."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -374,8 +382,10 @@ function generateChannelArtifacts() {
|
||||||
echo "#################################################################"
|
echo "#################################################################"
|
||||||
echo "####### Generating anchor peer update for Org2MSP ##########"
|
echo "####### Generating anchor peer update for Org2MSP ##########"
|
||||||
echo "#################################################################"
|
echo "#################################################################"
|
||||||
|
set -x
|
||||||
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate \
|
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate \
|
||||||
./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP
|
./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP
|
||||||
|
set +x
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
echo "Failed to generate anchor peer update for Org2MSP..."
|
echo "Failed to generate anchor peer update for Org2MSP..."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,8 @@ services:
|
||||||
environment:
|
environment:
|
||||||
- GOPATH=/opt/gopath
|
- GOPATH=/opt/gopath
|
||||||
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
|
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
|
||||||
- CORE_LOGGING_LEVEL=DEBUG
|
#- CORE_LOGGING_LEVEL=DEBUG
|
||||||
|
- CORE_LOGGING_LEVEL=INFO
|
||||||
- CORE_PEER_ID=cli
|
- CORE_PEER_ID=cli
|
||||||
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
|
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
|
||||||
- CORE_PEER_LOCALMSPID=Org1MSP
|
- CORE_PEER_LOCALMSPID=Org1MSP
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,8 @@ services:
|
||||||
environment:
|
environment:
|
||||||
- GOPATH=/opt/gopath
|
- GOPATH=/opt/gopath
|
||||||
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
|
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
|
||||||
- CORE_LOGGING_LEVEL=DEBUG
|
- CORE_LOGGING_LEVEL=INFO
|
||||||
|
#- CORE_LOGGING_LEVEL=DEBUG
|
||||||
- CORE_PEER_ID=Org3cli
|
- CORE_PEER_ID=Org3cli
|
||||||
- CORE_PEER_ADDRESS=peer0.org3.example.com:7051
|
- CORE_PEER_ADDRESS=peer0.org3.example.com:7051
|
||||||
- CORE_PEER_LOCALMSPID=Org3MSP
|
- CORE_PEER_LOCALMSPID=Org3MSP
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,9 @@ function generateCerts (){
|
||||||
echo "###############################################################"
|
echo "###############################################################"
|
||||||
|
|
||||||
(cd org3-artifacts
|
(cd org3-artifacts
|
||||||
|
set -x
|
||||||
cryptogen generate --config=./org3-crypto.yaml
|
cryptogen generate --config=./org3-crypto.yaml
|
||||||
|
set +x
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
echo "Failed to generate certificates..."
|
echo "Failed to generate certificates..."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -203,7 +205,9 @@ function generateChannelArtifacts() {
|
||||||
echo "##########################################################"
|
echo "##########################################################"
|
||||||
(cd org3-artifacts
|
(cd org3-artifacts
|
||||||
export FABRIC_CFG_PATH=$PWD
|
export FABRIC_CFG_PATH=$PWD
|
||||||
|
set -x
|
||||||
configtxgen -printOrg Org3MSP > ../channel-artifacts/org3.json
|
configtxgen -printOrg Org3MSP > ../channel-artifacts/org3.json
|
||||||
|
set +x
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
echo "Failed to generate Org3 config material..."
|
echo "Failed to generate Org3 config material..."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,9 @@ createChannel() {
|
||||||
setGlobals 0 1
|
setGlobals 0 1
|
||||||
|
|
||||||
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
|
||||||
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
|
||||||
|
set +x
|
||||||
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
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,9 @@ apt-get -y update && apt-get -y install jq
|
||||||
fetchChannelConfig ${CHANNEL_NAME} config.json
|
fetchChannelConfig ${CHANNEL_NAME} config.json
|
||||||
|
|
||||||
# Modify the configuration to append the new org
|
# Modify the configuration to append the new org
|
||||||
|
set -x
|
||||||
jq -s '.[0] * {"channel_group":{"groups":{"Application":{"groups": {"Org3MSP":.[1]}}}}}' config.json ./channel-artifacts/org3.json > modified_config.json
|
jq -s '.[0] * {"channel_group":{"groups":{"Application":{"groups": {"Org3MSP":.[1]}}}}}' config.json ./channel-artifacts/org3.json > modified_config.json
|
||||||
|
set +x
|
||||||
|
|
||||||
# Compute a config update, based on the differences between config.json and modified_config.json, write it as a transaction to org3_update_in_envelope.pb
|
# Compute a config update, based on the differences between config.json and modified_config.json, write it as a transaction to org3_update_in_envelope.pb
|
||||||
createConfigUpdate ${CHANNEL_NAME} config.json modified_config.json org3_update_in_envelope.pb
|
createConfigUpdate ${CHANNEL_NAME} config.json modified_config.json org3_update_in_envelope.pb
|
||||||
|
|
@ -60,7 +62,9 @@ echo
|
||||||
echo "========= Submitting transaction from a different peer (peer0.org2) which also signs it ========= "
|
echo "========= Submitting transaction from a different peer (peer0.org2) which also signs it ========= "
|
||||||
echo
|
echo
|
||||||
setGlobals 0 2
|
setGlobals 0 2
|
||||||
|
set -x
|
||||||
peer channel update -f org3_update_in_envelope.pb -c ${CHANNEL_NAME} -o orderer.example.com:7050 --tls --cafile ${ORDERER_CA}
|
peer channel update -f org3_update_in_envelope.pb -c ${CHANNEL_NAME} -o orderer.example.com:7050 --tls --cafile ${ORDERER_CA}
|
||||||
|
set +x
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "========= Config transaction to add org3 to network submitted! =========== "
|
echo "========= Config transaction to add org3 to network submitted! =========== "
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,9 @@ fi
|
||||||
. scripts/utils.sh
|
. scripts/utils.sh
|
||||||
|
|
||||||
echo "Fetching channel config block from orderer..."
|
echo "Fetching channel config block from orderer..."
|
||||||
|
set -x
|
||||||
peer channel fetch 0 $CHANNEL_NAME.block -o orderer.example.com:7050 -c $CHANNEL_NAME --tls --cafile $ORDERER_CA >&log.txt
|
peer channel fetch 0 $CHANNEL_NAME.block -o orderer.example.com:7050 -c $CHANNEL_NAME --tls --cafile $ORDERER_CA >&log.txt
|
||||||
|
set +x
|
||||||
res=$?
|
res=$?
|
||||||
cat log.txt
|
cat log.txt
|
||||||
verifyResult $res "Fetching config block from orderer has Failed"
|
verifyResult $res "Fetching config block from orderer has Failed"
|
||||||
|
|
|
||||||
|
|
@ -85,9 +85,13 @@ addCapabilityToChannel() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
||||||
peer channel update -f config_update_in_envelope.pb -c $CH_NAME -o orderer.example.com:7050 --cafile $ORDERER_CA
|
peer channel update -f config_update_in_envelope.pb -c $CH_NAME -o orderer.example.com:7050 --cafile $ORDERER_CA
|
||||||
|
set +x
|
||||||
else
|
else
|
||||||
|
set -x
|
||||||
peer channel update -f config_update_in_envelope.pb -c $CH_NAME -o orderer.example.com:7050 --tls true --cafile $ORDERER_CA
|
peer channel update -f config_update_in_envelope.pb -c $CH_NAME -o orderer.example.com:7050 --tls true --cafile $ORDERER_CA
|
||||||
|
set +x
|
||||||
fi
|
fi
|
||||||
res=$?
|
res=$?
|
||||||
verifyResult $res "Config update for \"$GROUP\" on \"$CH_NAME\" failed"
|
verifyResult $res "Config update for \"$GROUP\" on \"$CH_NAME\" failed"
|
||||||
|
|
|
||||||
|
|
@ -69,9 +69,13 @@ updateAnchorPeers() {
|
||||||
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
|
||||||
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
|
||||||
|
set +x
|
||||||
else
|
else
|
||||||
|
set -x
|
||||||
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
|
||||||
|
set +x
|
||||||
fi
|
fi
|
||||||
res=$?
|
res=$?
|
||||||
cat log.txt
|
cat log.txt
|
||||||
|
|
@ -87,7 +91,9 @@ joinChannelWithRetry () {
|
||||||
ORG=$2
|
ORG=$2
|
||||||
setGlobals $PEER $ORG
|
setGlobals $PEER $ORG
|
||||||
|
|
||||||
|
set -x
|
||||||
peer channel join -b $CHANNEL_NAME.block >&log.txt
|
peer channel join -b $CHANNEL_NAME.block >&log.txt
|
||||||
|
set +x
|
||||||
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
|
||||||
|
|
@ -106,7 +112,9 @@ installChaincode () {
|
||||||
ORG=$2
|
ORG=$2
|
||||||
setGlobals $PEER $ORG
|
setGlobals $PEER $ORG
|
||||||
VERSION=${3:-1.0}
|
VERSION=${3:-1.0}
|
||||||
|
set -x
|
||||||
peer chaincode install -n mycc -v ${VERSION} -l ${LANGUAGE} -p ${CC_SRC_PATH} >&log.txt
|
peer chaincode install -n mycc -v ${VERSION} -l ${LANGUAGE} -p ${CC_SRC_PATH} >&log.txt
|
||||||
|
set +x
|
||||||
res=$?
|
res=$?
|
||||||
cat log.txt
|
cat log.txt
|
||||||
verifyResult $res "Chaincode installation on peer${PEER}.org${ORG} has Failed"
|
verifyResult $res "Chaincode installation on peer${PEER}.org${ORG} has Failed"
|
||||||
|
|
@ -123,9 +131,13 @@ instantiateChaincode () {
|
||||||
# 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
|
||||||
|
set -x
|
||||||
peer chaincode instantiate -o orderer.example.com:7050 -C $CHANNEL_NAME -n mycc -l ${LANGUAGE} -v ${VERSION} -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')" >&log.txt
|
peer chaincode instantiate -o orderer.example.com:7050 -C $CHANNEL_NAME -n mycc -l ${LANGUAGE} -v ${VERSION} -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')" >&log.txt
|
||||||
|
set +x
|
||||||
else
|
else
|
||||||
|
set -x
|
||||||
peer chaincode instantiate -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -l ${LANGUAGE} -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')" >&log.txt
|
peer chaincode instantiate -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -l ${LANGUAGE} -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')" >&log.txt
|
||||||
|
set +x
|
||||||
fi
|
fi
|
||||||
res=$?
|
res=$?
|
||||||
cat log.txt
|
cat log.txt
|
||||||
|
|
@ -139,7 +151,9 @@ upgradeChaincode () {
|
||||||
ORG=$2
|
ORG=$2
|
||||||
setGlobals $PEER $ORG
|
setGlobals $PEER $ORG
|
||||||
|
|
||||||
|
set -x
|
||||||
peer chaincode upgrade -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -v 2.0 -c '{"Args":["init","a","90","b","210"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer','Org3MSP.peer')"
|
peer chaincode upgrade -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -v 2.0 -c '{"Args":["init","a","90","b","210"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer','Org3MSP.peer')"
|
||||||
|
set +x
|
||||||
res=$?
|
res=$?
|
||||||
cat log.txt
|
cat log.txt
|
||||||
verifyResult $res "Chaincode upgrade on org${ORG} peer${PEER} has Failed"
|
verifyResult $res "Chaincode upgrade on org${ORG} peer${PEER} has Failed"
|
||||||
|
|
@ -162,7 +176,9 @@ chaincodeQuery () {
|
||||||
do
|
do
|
||||||
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
|
||||||
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
|
||||||
|
set +x
|
||||||
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" = "$EXPECTED_RESULT" && let rc=0
|
test "$VALUE" = "$EXPECTED_RESULT" && let rc=0
|
||||||
done
|
done
|
||||||
|
|
@ -188,13 +204,19 @@ fetchChannelConfig() {
|
||||||
|
|
||||||
echo "Fetching the most recent configuration block for the channel"
|
echo "Fetching the most recent configuration block for the channel"
|
||||||
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
|
||||||
peer channel fetch config config_block.pb -o orderer.example.com:7050 -c $CHANNEL --cafile $ORDERER_CA
|
peer channel fetch config config_block.pb -o orderer.example.com:7050 -c $CHANNEL --cafile $ORDERER_CA
|
||||||
|
set +x
|
||||||
else
|
else
|
||||||
|
set -x
|
||||||
peer channel fetch config config_block.pb -o orderer.example.com:7050 -c $CHANNEL --tls --cafile $ORDERER_CA
|
peer channel fetch config config_block.pb -o orderer.example.com:7050 -c $CHANNEL --tls --cafile $ORDERER_CA
|
||||||
|
set +x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Decoding config block to JSON and isolating config to ${OUTPUT}"
|
echo "Decoding config block to JSON and isolating config to ${OUTPUT}"
|
||||||
|
set -x
|
||||||
configtxlator proto_decode --input config_block.pb --type common.Block | jq .data.data[0].payload.data.config > "${OUTPUT}"
|
configtxlator proto_decode --input config_block.pb --type common.Block | jq .data.data[0].payload.data.config > "${OUTPUT}"
|
||||||
|
set +x
|
||||||
}
|
}
|
||||||
|
|
||||||
# signConfigtxAsPeerOrg <org> <configtx.pb>
|
# signConfigtxAsPeerOrg <org> <configtx.pb>
|
||||||
|
|
@ -203,7 +225,9 @@ signConfigtxAsPeerOrg() {
|
||||||
PEERORG=$1
|
PEERORG=$1
|
||||||
TX=$2
|
TX=$2
|
||||||
setGlobals 0 $PEERORG
|
setGlobals 0 $PEERORG
|
||||||
|
set -x
|
||||||
peer channel signconfigtx -f "${TX}"
|
peer channel signconfigtx -f "${TX}"
|
||||||
|
set +x
|
||||||
}
|
}
|
||||||
|
|
||||||
# createConfigUpdate <channel_id> <original_config.json> <modified_config.json> <output.pb>
|
# createConfigUpdate <channel_id> <original_config.json> <modified_config.json> <output.pb>
|
||||||
|
|
@ -214,12 +238,14 @@ createConfigUpdate() {
|
||||||
MODIFIED=$3
|
MODIFIED=$3
|
||||||
OUTPUT=$4
|
OUTPUT=$4
|
||||||
|
|
||||||
|
set -x
|
||||||
configtxlator proto_encode --input "${ORIGINAL}" --type common.Config > original_config.pb
|
configtxlator proto_encode --input "${ORIGINAL}" --type common.Config > original_config.pb
|
||||||
configtxlator proto_encode --input "${MODIFIED}" --type common.Config > modified_config.pb
|
configtxlator proto_encode --input "${MODIFIED}" --type common.Config > modified_config.pb
|
||||||
configtxlator compute_update --channel_id "${CHANNEL}" --original original_config.pb --updated modified_config.pb > config_update.pb
|
configtxlator compute_update --channel_id "${CHANNEL}" --original original_config.pb --updated modified_config.pb > config_update.pb
|
||||||
configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate > config_update.json
|
configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate > config_update.json
|
||||||
echo '{"payload":{"header":{"channel_header":{"channel_id":"'$CHANNEL'", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' | jq . > config_update_in_envelope.json
|
echo '{"payload":{"header":{"channel_header":{"channel_id":"'$CHANNEL'", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' | jq . > config_update_in_envelope.json
|
||||||
configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope > "${OUTPUT}"
|
configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope > "${OUTPUT}"
|
||||||
|
set +x
|
||||||
}
|
}
|
||||||
|
|
||||||
chaincodeInvoke () {
|
chaincodeInvoke () {
|
||||||
|
|
@ -229,9 +255,13 @@ chaincodeInvoke () {
|
||||||
# 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
|
||||||
|
set -x
|
||||||
peer chaincode invoke -o orderer.example.com:7050 -C $CHANNEL_NAME -n mycc -c '{"Args":["invoke","a","b","10"]}' >&log.txt
|
peer chaincode invoke -o orderer.example.com:7050 -C $CHANNEL_NAME -n mycc -c '{"Args":["invoke","a","b","10"]}' >&log.txt
|
||||||
|
set +x
|
||||||
else
|
else
|
||||||
|
set -x
|
||||||
peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -c '{"Args":["invoke","a","b","10"]}' >&log.txt
|
peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -c '{"Args":["invoke","a","b","10"]}' >&log.txt
|
||||||
|
set +x
|
||||||
fi
|
fi
|
||||||
res=$?
|
res=$?
|
||||||
cat log.txt
|
cat log.txt
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue