diff --git a/hyperledger_fabric/test/cc-discover.sh b/hyperledger_fabric/test/cc-discover.sh new file mode 100644 index 00000000..25c0c49a --- /dev/null +++ b/hyperledger_fabric/test/cc-discover.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Invoke a chaincode +# Usage: ./script mspId channel peerAddr ccName mspPath=${PWD}/msp-mspId + +# Entry function +main() { + if [ $# -lt 4 ]; then + echo "Not enough argument supplied" + echo "$(basename $0) mspId channel peerAddr ccName mspPath=${PWD}/msp-mspId" + exit 1 + fi + + local mspId=$1 + local channel=$2 + local peerAddr=$3 + local ccName=$4 + local mspPath=${5:-${PWD}/msp-${mspId}} # Suppose the local msp path named as msp-${msp_id} + + export FABRIC_LOGGING_SPEC="debug" + export CORE_PEER_ADDRESS="${peerAddr}" + export CORE_PEER_LOCALMSPID=${mspId} + export CORE_PEER_MSPCONFIGPATH=${mspPath} + export CORE_PEER_TLS_ROOTCERT_FILE=${mspPath}/tlscacerts/tlsca.cert + export CORE_PEER_TLS_ENABLED=true + + discover \ + --peerTLSCA "${CORE_PEER_TLS_ROOTCERT_FILE}" \ + --userKey ${mspPath}/keystore/${mspId}-key \ + --userCert ${mspPath}/signcerts/${mspId}-cert.pem \ + --MSP "${mspId}" \ + endorsers \ + --channel "${channel}" \ + --chaincode "${ccName}" \ + --server "${peerAddr}" + #--tlsCert tls/client.crt \ + #--tlsKey tls/client.key \ +} + +main "$@" diff --git a/hyperledger_fabric/test/cc-invoke.sh b/hyperledger_fabric/test/cc-invoke.sh new file mode 100644 index 00000000..80415bf2 --- /dev/null +++ b/hyperledger_fabric/test/cc-invoke.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# Invoke a chaincode +# Usage: ./script mspId channel ordererAddr peerAddr ccName mspPath=${PWD}/msp-mspId + +# Entry function +main() { + if [ $# -lt 5 ]; then + echo "Not enough argument supplied" + echo "$(basename $0) mspId channel ordererAddr peerAddr ccName mspPath=${PWD}/msp-mspId" + exit 1 + fi + + local mspId=$1 + local channel=$2 + local ordererAddr=$3 + local peerAddr=$4 + local ccName=$5 + local mspPath=${6:-${PWD}/msp-${mspId}} # Suppose the local msp path named as msp-${msp_id} + + export FABRIC_LOGGING_SPEC="debug" + export CORE_PEER_ADDRESS="${peerAddr}" + export CORE_PEER_LOCALMSPID=${mspId} + export CORE_PEER_MSPCONFIGPATH=${mspPath} + export CORE_PEER_TLS_ROOTCERT_FILE=${mspPath}/tlscacerts/tlsca.cert + export CORE_PEER_TLS_ENABLED=true + + peer chaincode invoke \ + --connTimeout="30s" \ + -o "${ordererAddr}" \ + -C "${channel}" \ + -n "${ccName}" \ + --peerAddresses "${peerAddr}" \ + --tlsRootCertFiles "${CORE_PEER_TLS_ROOTCERT_FILE}" \ + -c '{"Args":["invoke","a","b","10"]}' \ + --tls \ + --cafile "${CORE_PEER_TLS_ROOTCERT_FILE}" + + exit 0 + + peer chaincode query \ + --connTimeout=30s \ + -C "${channel}" \ + -n "${ccName}" \ + --peerAddresses "${peerAddr}" \ + --tlsRootCertFiles "${CORE_PEER_TLS_ROOTCERT_FILE}" \ + -c '{"Args":["query","b"]}' +} + +main "$@" diff --git a/hyperledger_fabric/test/cc-list.sh b/hyperledger_fabric/test/cc-list.sh new file mode 100644 index 00000000..b3ad7140 --- /dev/null +++ b/hyperledger_fabric/test/cc-list.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# Invoke a chaincode +# Usage: ./script mspId peerAddr mspPath=${PWD}/msp-mspId + +# Entry function +main() { + if [ $# -lt 2 ]; then + echo "Not enough argument supplied" + echo "$(basename $0) mspId peerAddr mspPath=${PWD}/msp-mspId" + exit 1 + fi + + local mspId=$1 + local peerAddr=$2 + local mspPath=${3:-${PWD}/msp-${mspId}} # Suppose the local msp path named as msp-${msp_id} + + export FABRIC_LOGGING_SPEC="debug" + export CORE_PEER_ADDRESS="${peerAddr}" + export CORE_PEER_LOCALMSPID=${mspId} + export CORE_PEER_MSPCONFIGPATH=${mspPath} + export CORE_PEER_TLS_ROOTCERT_FILE=${mspPath}/tlscacerts/tlsca.cert + export CORE_PEER_TLS_ENABLED=true + + #export GRPC_GO_REQUIRE_HANDSHAKE=off + + peer chaincode list \ + --connTimeout=30s \ + --installed \ + --peerAddresses "${peerAddr}" \ + --tlsRootCertFiles "${CORE_PEER_TLS_ROOTCERT_FILE}" + + exit 0 +} + +main "$@" diff --git a/hyperledger_fabric/test/fetch-config-block.sh b/hyperledger_fabric/test/fetch-config-block.sh index 2c3952f4..459a1d26 100644 --- a/hyperledger_fabric/test/fetch-config-block.sh +++ b/hyperledger_fabric/test/fetch-config-block.sh @@ -45,10 +45,10 @@ fetchConfigBlock() { --tls \ --cafile "${tlscaFile}" - echo "[${channel}] Decode config block into JSON with configtxlator" + echo "[${channel}] Decode config block into ${channel}_config.block.json" configtxlatorDecode "common.Block" "${channel}_config.block" "${channel}_config.block.json" - echo "[${channel}] Export the config section ${PAYLOAD_CFG_PATH} from config block" + echo "[${channel}] Export the config section ${PAYLOAD_CFG_PATH} from config block into ${channel}_config.block.cfg.json" jq "${PAYLOAD_CFG_PATH}" "${channel}_config.block.json" >"${channel}_config.block.cfg.json" } @@ -62,6 +62,7 @@ main() { if [ $# -lt 3 ]; then echo "Not enough argument supplied" echo "$(basename $0) mspId channel ordererURL mspPath=${PWD}/msp-mspId" + exit 1 fi local mspId=$1 local channel=$2