docker-compose-files/hyperledger_fabric/v1.0.2/scripts/test_cc_invoke_query.sh

41 lines
1.3 KiB
Bash
Raw Normal View History

2017-09-01 20:09:18 +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-01 09:49:26 +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-09-01 20:09:18 +08:00
#Query on chaincode on Peer0/Org1
2018-01-18 13:31:00 +08:00
echo_g "=== Testing Chaincode invoke/query ==="
2018-01-14 19:49:20 +08:00
echo_b "Querying chaincode ${CC_NAME} on peer org2/peer0..."
chaincodeQuery ${APP_CHANNEL} 2 1 ${CC_NAME} ${CC_QUERY_ARGS} 100
2017-09-01 20:09:18 +08:00
#Invoke on chaincode on Peer0/Org1
echo_b "Sending invoke transaction (transfer 10) on org1/peer0..."
2018-01-14 19:49:20 +08:00
chaincodeInvoke ${APP_CHANNEL} 1 0 ${CC_NAME} ${CC_INVOKE_ARGS}
2017-09-01 20:09:18 +08:00
#Query on chaincode on Peer1/Org2, check if the result is 90
2017-09-11 10:33:29 +08:00
echo_b "Querying chaincode on peer 1 and 3..."
2018-01-14 19:49:20 +08:00
chaincodeQuery ${APP_CHANNEL} 1 1 ${CC_NAME} ${CC_QUERY_ARGS} 90
chaincodeQuery ${APP_CHANNEL} 2 1 ${CC_NAME} ${CC_QUERY_ARGS} 90
2017-09-01 20:09:18 +08:00
#Invoke on chaincode on Peer1/Org2
echo_b "Sending invoke transaction on org2/peer3..."
2018-01-14 19:49:20 +08:00
chaincodeInvoke ${APP_CHANNEL} 2 1 ${CC_NAME} ${CC_INVOKE_ARGS}
2017-09-01 20:09:18 +08:00
#Query on chaincode on Peer1/Org2, check if the result is 80
echo_b "Querying chaincode on all 4peers..."
2018-01-14 19:49:20 +08:00
chaincodeQuery ${APP_CHANNEL} 1 0 ${CC_NAME} ${CC_QUERY_ARGS} 80
chaincodeQuery ${APP_CHANNEL} 2 0 ${CC_NAME} ${CC_QUERY_ARGS} 80
2017-09-01 20:09:18 +08:00
2018-01-18 13:31:00 +08:00
echo_g "=== Chaincode invoke/query completed ==="
echo