github.com/inklabsfoundation/inkchain@v0.17.1-0.20181025012015-c3cef8062f19/examples/cli_test/scripts/test_inkwork.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 #i07caf88941eafcaaa3370657fccc261acb75dfba 11 #70698e364537a106b5aa5332d660e2234b37eebcb3768a2a97ffb8042dfe2fc4 12 13 #user account 14 #ia5ff00eb44bf19d5dfbde501c90e286badb58df4 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 issueToken(){ 49 peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C ${CHANNEL_NAME} -n ascc -c '{"Args":["registerAndIssueToken","'$1'","1000000000000000","18","i07caf88941eafcaaa3370657fccc261acb75dfba"]}' >log.txt 50 res=$? 51 cat log.txt 52 verifyResult $res "Issue a new token using ascc has Failed." 53 echo_g "===================== A new token has been successfully issued======================= " 54 echo 55 } 56 57 makeTransfer(){ 58 echo_b "pls wait 5 secs..." 59 sleep 5 60 peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C ${CHANNEL_NAME} -n token -c '{"Args":["transfer","ia5ff00eb44bf19d5dfbde501c90e286badb58df4","INK","50000000000000"]}' -i "1000000000" -z 70698e364537a106b5aa5332d660e2234b37eebcb3768a2a97ffb8042dfe2fc4 >log.txt 61 res=$? 62 cat log.txt 63 verifyResult $res "Make transfer has Failed." 64 echo_g "===================== Make transfer success ======================= " 65 echo 66 } 67 68 registerWork(){ 69 sleep 3 70 peer chaincode invoke -C mychannel -n inkwork --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["registerWork","2018","2","4"]}' -i "100000000" -z 70698e364537a106b5aa5332d660e2234b37eebcb3768a2a97ffb8042dfe2fc4 >&log.txt 71 res=$? 72 cat log.txt 73 verifyResult $res "registerWork invoke has Failed." 74 echo_g "===================== registerWork invoke successfully======================= " 75 echo 76 } 77 78 sell(){ 79 sleep 3 80 peer chaincode invoke -C mychannel -n inkwork --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["sell","2018","10","1"]}' -i "100000000" -z 70698e364537a106b5aa5332d660e2234b37eebcb3768a2a97ffb8042dfe2fc4 >&log.txt 81 res=$? 82 cat log.txt 83 verifyResult $res "inkwork invoke has Failed." 84 echo_g "===================== inkwork sell successfully======================= " 85 echo 86 } 87 88 purchase(){ 89 sleep 3 90 peer chaincode invoke -C mychannel -n inkwork --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["purchase","2018"]}' -i "100000000" -z 344c267e5acb2ac9107465fc85eba24cbb17509e918c3cc3f5098dddf42167e5 >&log.txt 91 res=$? 92 cat log.txt 93 verifyResult $res "inkwork invoke has Failed." 94 echo_g "===================== inkwor purchase successfully======================= " 95 echo 96 } 97 98 inkworkQuery () { 99 sleep 3 100 peer chaincode query -C mychannel -n inkwork -c '{"Args":["queryInkwork","2018"]}' >log.txt 101 res=$? 102 cat log.txt 103 verifyResult $res "query inkwork Failed." 104 echo_g "===================== inkwork query successfully======================= " 105 echo 106 } 107 108 listQuery () { 109 sleep 3 110 peer chaincode query -C mychannel -n inkwork -c '{"Args":["query","1"]}' >log.txt 111 res=$? 112 cat log.txt 113 verifyResult $res "query inkwork list Failed." 114 echo_g "===================== list query successfully======================= " 115 echo 116 } 117 118 119 echo_b "=====================register token=======================" 120 issueToken INK 121 makeTransfer 122 123 echo_b "=====================1.registerWork=======================" 124 registerWork 125 126 echo_b "=====================2.sell work=======================" 127 sell 128 129 echo_b "=====================3.purchase purchase=======================" 130 purchase 131 132 echo_b "=====================4.inkworkQuery=======================" 133 inkworkQuery 134 135 echo_b "=====================5.listQuery=======================" 136 listQuery 137 138 echo 139 echo_g "=====================All GOOD, MVE Test completed ===================== " 140 echo 141 exit 0 142