diff --git a/test-network/network.sh b/test-network/network.sh index 91da1d0a..27ac0590 100755 --- a/test-network/network.sh +++ b/test-network/network.sh @@ -224,10 +224,9 @@ function createOrgs() { infoln "Generating certificates using Fabric CA" ${CONTAINER_CLI_COMPOSE} -f compose/$COMPOSE_FILE_CA -f compose/$CONTAINER_CLI/${CONTAINER_CLI}-$COMPOSE_FILE_CA up -d 2>&1 - # Allow CAs to initialize and then make register and enroll requests - sleep 3 . organizations/fabric-ca/registerEnroll.sh + # Make sure CA files have been created while : do if [ ! -f "organizations/fabric-ca/org1/tls-cert.pem" ]; then @@ -237,6 +236,20 @@ function createOrgs() { fi done + # Make sure CA service is initialized and can accept requests before making register and enroll calls + export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/peerOrganizations/org1.example.com/ + COUNTER=0 + rc=1 + while [[ $rc -ne 0 && $COUNTER -lt $MAX_RETRY ]]; do + sleep 1 + set -x + fabric-ca-client getcainfo -u https://admin:adminpw@localhost:7054 --caname ca-org1 --tls.certfiles "${PWD}/organizations/fabric-ca/org1/ca-cert.pem" + res=$? + { set +x; } 2>/dev/null + rc=$res # Update rc + COUNTER=$((COUNTER + 1)) + done + infoln "Creating Org1 Identities" createOrg1