From 36ef14043969770d8b737af37fdab05316c105d2 Mon Sep 17 00:00:00 2001 From: Simon Stone Date: Fri, 12 Jul 2019 16:59:14 +0100 Subject: [PATCH] [FAB-15649]Fix Fabcar to install Chaincode on all peers CI Fabcar javascript test fails because a query proposal is sent to a peer which does not have Chaincode. The query handler in fabric-network does not consider if Chaincode is installed on target peers. As a workaround, this CR adds steps installing Chaincode on all peers during the setup. Signed-off-by: Simon Stone Change-Id: I771e3bae0abd2d6a3b3b7d295efdf6417c3c1c21 --- fabcar/startFabric.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/fabcar/startFabric.sh b/fabcar/startFabric.sh index c594b186..c4653c08 100755 --- a/fabcar/startFabric.sh +++ b/fabcar/startFabric.sh @@ -66,6 +66,19 @@ docker exec \ -p "$CC_SRC_PATH" \ -l "$CC_RUNTIME_LANGUAGE" +echo "Installing smart contract on peer1.org1.example.com" +docker exec \ + -e CORE_PEER_LOCALMSPID=Org1MSP \ + -e CORE_PEER_ADDRESS=peer1.org1.example.com:8051 \ + -e CORE_PEER_MSPCONFIGPATH=${ORG1_MSPCONFIGPATH} \ + -e CORE_PEER_TLS_ROOTCERT_FILE=${ORG1_TLS_ROOTCERT_FILE} \ + cli \ + peer chaincode install \ + -n fabcar \ + -v 1.0 \ + -p "$CC_SRC_PATH" \ + -l "$CC_RUNTIME_LANGUAGE" + echo "Installing smart contract on peer0.org2.example.com" docker exec \ -e CORE_PEER_LOCALMSPID=Org2MSP \ @@ -79,6 +92,19 @@ docker exec \ -p "$CC_SRC_PATH" \ -l "$CC_RUNTIME_LANGUAGE" +echo "Installing smart contract on peer1.org2.example.com" +docker exec \ + -e CORE_PEER_LOCALMSPID=Org2MSP \ + -e CORE_PEER_ADDRESS=peer1.org2.example.com:10051 \ + -e CORE_PEER_MSPCONFIGPATH=${ORG2_MSPCONFIGPATH} \ + -e CORE_PEER_TLS_ROOTCERT_FILE=${ORG2_TLS_ROOTCERT_FILE} \ + cli \ + peer chaincode install \ + -n fabcar \ + -v 1.0 \ + -p "$CC_SRC_PATH" \ + -l "$CC_RUNTIME_LANGUAGE" + echo "Instantiating smart contract on mychannel" docker exec \ -e CORE_PEER_LOCALMSPID=Org1MSP \ @@ -101,6 +127,7 @@ echo "Waiting for instantiation request to be committed ..." sleep 10 echo "Submitting initLedger transaction to smart contract on mychannel" +echo "The transaction is sent to all of the peers so that chaincode is built before receiving the following requests" docker exec \ -e CORE_PEER_LOCALMSPID=Org1MSP \ -e CORE_PEER_MSPCONFIGPATH=${ORG1_MSPCONFIGPATH} \ @@ -114,8 +141,12 @@ docker exec \ --tls \ --cafile ${ORDERER_TLS_ROOTCERT_FILE} \ --peerAddresses peer0.org1.example.com:7051 \ + --peerAddresses peer1.org1.example.com:8051 \ --peerAddresses peer0.org2.example.com:9051 \ + --peerAddresses peer1.org2.example.com:10051 \ --tlsRootCertFiles ${ORG1_TLS_ROOTCERT_FILE} \ + --tlsRootCertFiles ${ORG1_TLS_ROOTCERT_FILE} \ + --tlsRootCertFiles ${ORG2_TLS_ROOTCERT_FILE} \ --tlsRootCertFiles ${ORG2_TLS_ROOTCERT_FILE} set +x