2017-12-06 22:30:57 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Importing useful functions for cc testing
|
|
|
|
if [ -f ./func.sh ]; then
|
|
|
|
source ./func.sh
|
|
|
|
elif [ -f scripts/func.sh ]; then
|
|
|
|
source scripts/func.sh
|
|
|
|
fi
|
|
|
|
|
2018-03-05 14:10:16 +08:00
|
|
|
CC_NAME=${CC_NAME:-$CC_02_NAME}
|
|
|
|
CC_INVOKE_ARGS=${CC_INVOKE_ARGS:-$CC_02_INVOKE_ARGS}
|
|
|
|
CC_QUERY_ARGS=${CC_QUERY_ARGS:-$CC_02_QUERY_ARGS}
|
|
|
|
|
2017-12-06 22:30:57 +08:00
|
|
|
#Query on chaincode on Peer0/Org1
|
2018-10-11 13:53:01 +08:00
|
|
|
echo_b "=== Testing Chaincode invoke/query ==="
|
2018-01-30 15:54:49 +08:00
|
|
|
|
2019-04-21 11:18:26 +08:00
|
|
|
#Invoke on chaincode on Peer0/Org1
|
|
|
|
echo_b "Init chaincode by org1/peer0..."
|
2019-05-02 17:30:13 +08:00
|
|
|
chaincodeInit 1 0 ${APP_CHANNEL} "${ORDERER0_URL}" ${CC_NAME} ${CC_INIT_ARGS} "${ORG1_PEER0_URL}" "${ORG1_PEER0_TLS_ROOTCERT}"
|
2019-04-21 11:18:26 +08:00
|
|
|
|
2019-04-22 14:19:18 +08:00
|
|
|
sleep 5 # wait for chaincode is up
|
|
|
|
|
2018-08-22 17:27:45 +08:00
|
|
|
# Non-side-DB testing
|
2019-04-21 11:18:26 +08:00
|
|
|
echo_b "Query chaincode ${CC_NAME} on peer org1/peer0..."
|
2019-04-22 14:19:18 +08:00
|
|
|
chaincodeQuery 1 0 "${ORG1_PEER0_URL}" "${ORG1_PEER0_TLS_ROOTCERT}" ${APP_CHANNEL} ${CC_NAME} ${CC_QUERY_ARGS} 100
|
2017-12-06 22:30:57 +08:00
|
|
|
|
|
|
|
#Invoke on chaincode on Peer0/Org1
|
2018-08-22 17:27:45 +08:00
|
|
|
echo_b "Invoke transaction (transfer 10) by org1/peer0..."
|
2019-05-02 17:30:13 +08:00
|
|
|
chaincodeInvoke 1 0 "${ORG1_PEER0_URL}" "${ORG1_PEER0_TLS_ROOTCERT}" ${APP_CHANNEL} "${ORDERER0_URL}" ${ORDERER0_TLS_ROOTCERT} ${CC_NAME} ${CC_INVOKE_ARGS}
|
2017-12-06 22:30:57 +08:00
|
|
|
|
|
|
|
#Query on chaincode on Peer1/Org2, check if the result is 90
|
2018-08-22 17:27:45 +08:00
|
|
|
echo_b "Query chaincode on org2/peer1..."
|
2019-04-22 14:19:18 +08:00
|
|
|
chaincodeQuery 2 1 "${ORG1_PEER0_URL}" "${ORG1_PEER0_TLS_ROOTCERT}" ${APP_CHANNEL} ${CC_NAME} ${CC_QUERY_ARGS} 90
|
2017-12-06 22:30:57 +08:00
|
|
|
|
|
|
|
#Invoke on chaincode on Peer1/Org2
|
2018-08-22 17:27:45 +08:00
|
|
|
echo_b "Send invoke transaction on org2/peer1..."
|
2019-05-02 17:30:13 +08:00
|
|
|
chaincodeInvoke 2 1 "${ORG1_PEER0_URL}" "${ORG1_PEER0_TLS_ROOTCERT}" ${APP_CHANNEL} "${ORDERER0_URL}" ${ORDERER0_TLS_ROOTCERT} ${CC_NAME} ${CC_INVOKE_ARGS}
|
2017-12-06 22:30:57 +08:00
|
|
|
|
|
|
|
#Query on chaincode on Peer1/Org2, check if the result is 80
|
2018-08-22 17:27:45 +08:00
|
|
|
echo_b "Query chaincode on org1/peer0 4peers..."
|
2019-04-22 14:19:18 +08:00
|
|
|
chaincodeQuery 1 0 "${ORG1_PEER0_URL}" "${ORG1_PEER0_TLS_ROOTCERT}" ${APP_CHANNEL} ${CC_NAME} ${CC_QUERY_ARGS} 80
|
2018-08-22 17:27:45 +08:00
|
|
|
|
2018-10-11 13:53:01 +08:00
|
|
|
echo_g "=== Chaincode invoke/query done ==="
|