github.com/inklabsfoundation/inkchain@v0.17.1-0.20181025012015-c3cef8062f19/examples/cli_test/scripts/test_asset_edit.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 assetQuery_Asset () { 41 echo_b "Attempting to Query asset " 42 sleep 3 43 peer chaincode query -C mychannel -n asset -c '{"Args":["readAsset","Blockchain Guide"]}' >log.txt 44 45 res=$? 46 cat log.txt 47 verifyResult $res "query asset Failed." 48 } 49 50 assetInvoke_Edit_TYPE(){ 51 52 sleep 3 53 peer chaincode invoke -C mychannel -n asset --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["editAsset","Blockchain Guide","Type","E-Book"]}' -i "10" -z 70698e364537a106b5aa5332d660e2234b37eebcb3768a2a97ffb8042dfe2fc4 >&log.txt 54 res=$? 55 cat log.txt 56 verifyResult $res "asset invoke: editAsset has Failed." 57 echo_g "===================== asset invoke successfully======================= " 58 echo 59 } 60 61 assetInvoke_Edit_CONTENT(){ 62 63 sleep 3 64 peer chaincode invoke -C mychannel -n asset --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["editAsset","Blockchain Guide","Content","a e-book version."]}' -i "10" -z 70698e364537a106b5aa5332d660e2234b37eebcb3768a2a97ffb8042dfe2fc4 >&log.txt 65 res=$? 66 cat log.txt 67 verifyResult $res "asset invoke: editAsset has Failed." 68 echo_g "===================== asset invoke successfully======================= " 69 echo 70 } 71 72 assetInvoke_Edit_PRICE_TYPE(){ 73 74 sleep 3 75 peer chaincode invoke -C mychannel -n asset --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["editAsset","Blockchain Guide","PriceType","INK"]}' -i "10" -z 70698e364537a106b5aa5332d660e2234b37eebcb3768a2a97ffb8042dfe2fc4 >&log.txt 76 res=$? 77 cat log.txt 78 verifyResult $res "asset invoke: editAsset has Failed." 79 echo_g "===================== asset invoke successfully======================= " 80 echo 81 } 82 83 assetInvoke_Edit_PRICE(){ 84 85 sleep 3 86 peer chaincode invoke -C mychannel -n asset --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["editAsset","Blockchain Guide","Price","8"]}' -i "10" -z 70698e364537a106b5aa5332d660e2234b37eebcb3768a2a97ffb8042dfe2fc4 >&log.txt 87 res=$? 88 cat log.txt 89 verifyResult $res "asset invoke: editAsset has Failed." 90 echo_g "===================== asset invoke successfully======================= " 91 echo 92 } 93 94 chaincodeQueryB () { 95 96 sleep 3 97 echo_b "Attempting to query account B's balance on peer " 98 sleep 3 99 peer chaincode query -C mychannel -n token -c '{"Args":["getBalance","ia5ff00eb44bf19d5dfbde501c90e286badb58df4","INK"]}' >log.txt 100 res=$? 101 cat log.txt 102 verifyResult $res "query account B Failed." 103 104 } 105 106 107 echo_b "=====================Test Asset's edit invoke=======================" 108 109 echo_b "=====================1.query asset=====================" 110 assetQuery_Asset 111 112 echo_b "=====================2.edit asset=====================" 113 assetInvoke_Edit_TYPE 114 assetInvoke_Edit_CONTENT 115 assetInvoke_Edit_PRICE_TYPE 116 assetInvoke_Edit_PRICE 117 118 echo_b "=====================3.query asset again=====================" 119 assetQuery_Asset 120 121 echo 122 echo_g "=====================All GOOD, MVE Test completed ===================== " 123 echo 124 exit 0 125