github.com/inklabsfoundation/inkchain@v0.17.1-0.20181025012015-c3cef8062f19/examples/cli_test/scripts/test_cat_query.sh (about) 1 #!/usr/bin/env bash 2 3 # 4 #Copyright Ziggurat Corp. 2017 All Rights Reserved. 5 # 6 #SPDX-License-Identifier: Apache-2.0 7 # 8 9 # Detecting whether can import the header file to render colorful cli output 10 if [ -f ./header.sh ]; then 11 source ./header.sh 12 elif [ -f scripts/header.sh ]; then 13 source scripts/header.sh 14 else 15 alias echo_r="echo" 16 alias echo_g="echo" 17 alias echo_b="echo" 18 fi 19 20 CHANNEL_NAME="$1" 21 : ${CHANNEL_NAME:="mychannel"} 22 : ${TIMEOUT:="60"} 23 COUNTER=0 24 MAX_RETRY=5 25 26 ORDERER_CA=/opt/gopath/src/github.com/inklabsfoundation/inkchain/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem 27 28 echo_b "Chaincode Path : "$CC_PATH 29 echo_b "Channel name : "$CHANNEL_NAME 30 31 verifyResult () { 32 if [ $1 -ne 0 ] ; then 33 echo_b "!!!!!!!!!!!!!!! "$2" !!!!!!!!!!!!!!!!" 34 echo_r "================== ERROR !!! FAILED to execute MVE ==================" 35 echo 36 exit 1 37 fi 38 } 39 40 catQuery () { 41 echo_b "Attempting to Query cat" 42 sleep 3 43 peer chaincode query -C mychannel -n cat -c '{"Args":["query","7918"]}' >log.txt 44 res=$? 45 cat log.txt 46 verifyResult $res "query cat Failed." 47 echo_g "===================== cat query successfully======================= " 48 echo 49 } 50 51 catQueryAll () { 52 echo_b "Attempting to Query all cat " 53 sleep 3 54 peer chaincode query -C mychannel -n cat -c '{"Args":["queryAll"]}' >log.txt 55 res=$? 56 cat log.txt 57 verifyResult $res "query cat Failed." 58 echo_g "===================== cat query all successfully======================= " 59 echo 60 } 61 62 catQuerySale () { 63 echo_b "Attempting to Query sale cat " 64 sleep 3 65 peer chaincode query -C mychannel -n cat -c '{"Args":["querySale"]}' >log.txt 66 res=$? 67 cat log.txt 68 verifyResult $res "query cat Failed." 69 echo_g "===================== cat query sale successfully======================= " 70 echo 71 } 72 73 queryAuction() { 74 echo_b "Attempting to Query cat auction " 75 sleep 3 76 peer chaincode query -C mychannel -n cat -c '{"Args":["queryAuction","8415"]}' >log.txt 77 res=$? 78 cat log.txt 79 verifyResult $res "query cat auction Failed." 80 echo_g "===================== cat query auction successfully======================= " 81 echo 82 } 83 84 echo_b "=====================1.cat query all=====================" 85 catQueryAll 86 87 echo_b "=====================2.cat query sale=====================" 88 catQuerySale 89 90 echo_b "=====================3.cat query=====================" 91 catQuery 92 93 echo_b "=====================4.cat query auction=====================" 94 queryAuction 95 96 echo 97 echo_g "=====================All GOOD, MVE Test completed ===================== " 98 echo 99 exit 0 100