Skip to content

Commit

Permalink
Add chaincode logging for binary chaincode in test-network-nano-bash
Browse files Browse the repository at this point in the history
- Correct sh compability in ca_utils.sh
- Correct linux compatibility in external builder

Signed-off-by: Chris Elder <[email protected]>
Signed-off-by: Chris Elder <[email protected]>
  • Loading branch information
Chris Elder authored and denyeart committed Jun 14, 2024
1 parent 29e6951 commit 3622a5e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
6 changes: 3 additions & 3 deletions test-network-nano-bash/ca/ca_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Primary purpose it to create enrollment certificates for CA admins.
######################################################################################

function createEnrollment() {
createEnrollment() {

local port=$1 # port of the CA used for creating the enrollment
local username=$2 # username of the registered user on the CA
Expand All @@ -37,7 +37,7 @@ function createEnrollment() {
#
######################################################################################

function createMSP() {
createMSP() {

local caname=$1 # name of the ca (ordererca, org1ca, org2ca)
local orgname=$2 # name of the org (org1, org2) Ordering Org is blank
Expand All @@ -61,7 +61,7 @@ function createMSP() {
# enrollent and TLS certificates for peers and orderers.
######################################################################################

function registerAndEnroll() {
registerAndEnroll() {

local port=$1 # port of the CA used for creating the enrollment
local username=$2 # username of the user to register on the CA
Expand Down
5 changes: 3 additions & 2 deletions test-network-nano-bash/external_builders/golang/bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ exec 1>&2
BUILD_OUTPUT_DIR="$1"
RUN_METADATA_DIR="$2"

LOG_DIRECTORY=${PWD}/logs

#######################################
# Export environment variables and extract certificate files from chaincode.json
# Globals:
Expand Down Expand Up @@ -51,5 +53,4 @@ process_chaincode_metadata_json
# output for debug purposes
env | grep CORE | sort


exec "${BUILD_OUTPUT_DIR}/chaincode" -peer.address="${CORE_PEER_ADDRESS}"
exec "${BUILD_OUTPUT_DIR}/chaincode" -peer.address="${CORE_PEER_ADDRESS}" > ${LOG_DIRECTORY}/${CORE_CHAINCODE_ID_NAME}.log 2>&1
19 changes: 13 additions & 6 deletions test-network-nano-bash/external_builders/node/bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ exec 1>&2
BUILD_OUTPUT_DIR="$1"
RUN_METADATA_DIR="$2"

LOG_DIRECTORY=${PWD}/logs

cd "${BUILD_OUTPUT_DIR}"
ls -lart

Expand All @@ -34,12 +36,17 @@ else
jq -r .client_cert "$RUN_METADATA_DIR/chaincode.json" > "$CORE_TLS_CLIENT_CERT_FILE"
jq -r .client_key "$RUN_METADATA_DIR/chaincode.json" > "$CORE_TLS_CLIENT_KEY_FILE"
jq -r .root_cert "$RUN_METADATA_DIR/chaincode.json" > "$CORE_PEER_TLS_ROOTCERT_FILE"

base64 -i "${CORE_TLS_CLIENT_CERT_FILE}" > "${CORE_TLS_CLIENT_CERT_PATH}"
base64 -i "${CORE_TLS_CLIENT_KEY_FILE}" > "${CORE_TLS_CLIENT_KEY_PATH}"

#base64 -w 0 "${CORE_TLS_CLIENT_CERT_FILE}" > "${CORE_TLS_CLIENT_CERT_PATH}"
#base64 -w 0 "${CORE_TLS_CLIENT_KEY_FILE}" > "${CORE_TLS_CLIENT_KEY_PATH}"
if [ "${OSTYPE}" == "linux-gnu" ]; then
base64 -w 0 "${CORE_TLS_CLIENT_CERT_FILE}" > "${CORE_TLS_CLIENT_CERT_PATH}"
base64 -w 0 "${CORE_TLS_CLIENT_KEY_FILE}" > "${CORE_TLS_CLIENT_KEY_PATH}"
elif [[ "${OSTYPE}" == "darwin"* ]]; then
base64 -i "${CORE_TLS_CLIENT_CERT_FILE}" > "${CORE_TLS_CLIENT_CERT_PATH}"
base64 -i "${CORE_TLS_CLIENT_KEY_FILE}" > "${CORE_TLS_CLIENT_KEY_PATH}"
else
echo "OS "${OS}" not supported"
exit 1
fi

ls -lart "$BUILD_OUTPUT_DIR"
fi
Expand All @@ -48,4 +55,4 @@ fi
env | grep CORE | sort

# run the chaincode
exec npm start -- --peer.address="${CORE_PEER_ADDRESS}"
exec npm start -- --peer.address="${CORE_PEER_ADDRESS}" > ${LOG_DIRECTORY}/${CORE_CHAINCODE_ID_NAME}.log 2>&1

0 comments on commit 3622a5e

Please sign in to comment.