github.com/inklabsfoundation/inkchain@v0.17.1-0.20181025012015-c3cef8062f19/examples/cli_test/scripts/test_cat_auction.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 #system account 10 #07caf88941eafcaaa3370657fccc261acb75dfba 11 #70698e364537a106b5aa5332d660e2234b37eebcb3768a2a97ffb8042dfe2fc4 12 13 #user account 14 #a5ff00eb44bf19d5dfbde501c90e286badb58df4 15 #344c267e5acb2ac9107465fc85eba24cbb17509e918c3cc3f5098dddf42167e5 16 17 # Detecting whether can import the header file to render colorful cli output 18 if [ -f ./header.sh ]; then 19 source ./header.sh 20 elif [ -f scripts/header.sh ]; then 21 source scripts/header.sh 22 else 23 alias echo_r="echo" 24 alias echo_g="echo" 25 alias echo_b="echo" 26 fi 27 28 CHANNEL_NAME="$1" 29 : ${CHANNEL_NAME:="mychannel"} 30 : ${TIMEOUT:="60"} 31 COUNTER=0 32 MAX_RETRY=5 33 34 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 35 36 echo_b "Chaincode Path : "$CC_PATH 37 echo_b "Channel name : "$CHANNEL_NAME 38 39 verifyResult () { 40 if [ $1 -ne 0 ] ; then 41 echo_b "!!!!!!!!!!!!!!! "$2" !!!!!!!!!!!!!!!!" 42 echo_r "================== ERROR !!! FAILED to execute MVE ==================" 43 echo 44 exit 1 45 fi 46 } 47 48 catSystemInit(){ 49 sleep 3 50 peer chaincode invoke -C mychannel -n cat --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["initSystemCat"]}' -i "10" -z 70698e364537a106b5aa5332d660e2234b37eebcb3768a2a97ffb8042dfe2fc4 >&log.txt 51 res=$? 52 cat log.txt 53 verifyResult $res "cat invoke has Failed." 54 echo_g "===================== cat invoke successfully======================= " 55 echo 56 } 57 58 createAuction(){ 59 echo_b "Attempting to set cat createuction" 60 sleep 3 61 peer chaincode invoke -C mychannel -n cat --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["createAuction","8415","10","300"]}' -i "10" -z 70698e364537a106b5aa5332d660e2234b37eebcb3768a2a97ffb8042dfe2fc4 >&log.txt 62 res=$? 63 cat log.txt 64 verifyResult $res "cat invoke has Failed." 65 echo_g "===================== cat createAuction successfully======================= " 66 echo 67 } 68 69 bid(){ 70 echo_b "Attempting to bid cat " 71 sleep 3 72 peer chaincode invoke -C mychannel -n cat --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["bid","8415","310"]}' -i "10" -z 344c267e5acb2ac9107465fc85eba24cbb17509e918c3cc3f5098dddf42167e5 >log.txt 73 res=$? 74 cat log.txt 75 verifyResult $res "bid Cat has Failed." 76 echo_g "===================== bid cat success ======================= " 77 echo 78 } 79 80 endAuction(){ 81 echo_b "Attempting to endAuction" 82 sleep 3 83 peer chaincode invoke -C mychannel -n cat --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["endAuction","8415"]}' -i "10" -z 70698e364537a106b5aa5332d660e2234b37eebcb3768a2a97ffb8042dfe2fc4 >&log.txt 84 res=$? 85 cat log.txt 86 verifyResult $res "cat invoke has Failed." 87 echo_g "===================== cat endAuction successfully======================= " 88 echo 89 } 90 91 payAuction(){ 92 echo_b "Attempting to payAuction" 93 sleep 3 94 peer chaincode invoke -C mychannel -n cat --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["payAuction","8415","1","310"]}' -i "10" -z 344c267e5acb2ac9107465fc85eba24cbb17509e918c3cc3f5098dddf42167e5 >&log.txt 95 res=$? 96 cat log.txt 97 verifyResult $res "cat invoke has Failed." 98 echo_g "===================== cat payAuction successfully======================= " 99 echo 100 } 101 102 echo_b "=====================1.cat system init=======================" 103 catSystemInit 104 105 echo_b "=====================2.cat auction=======================" 106 createAuction 107 108 echo_b "=====================3.cat bid=======================" 109 bid 110 111 echo_b "=====================4.cat end auction=====================" 112 endAuction 113 114 echo_b "=====================5.cat pay auction=====================" 115 #payAuction 116 117 echo 118 echo_g "=====================All GOOD, MVE Test completed ===================== " 119 echo 120 exit 0 121