fabric-samples/full-stack-asset-transfer-guide/tests/10-appdev-e2e.sh
Mark S. Lewis 1aa3822788 Fix build with new microfab release
The new microfab release seems to start slower than the previous
release. This might be due to a change from solo to raft consensus. This
causes failures in the full-stack-asset-transfer appdev tests. Chaincode
deployment fails since the channel is not yet available.

Instead of increasing the sleep time after launching microfab, this
change attempts to wait however long is required by looking for the
"Microfab started" message in the container log before proceeding.

The test script is also updated to correctly stop the external chaincode
process when the script exits. Previously the process ID of the npm
command used to lauch the chaincode was captured rather than the actual
chaincode process.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-11-27 21:20:37 -05:00

56 lines
1.4 KiB
Bash
Executable file

#!/usr/bin/env bash
set -v -eou pipefail
# All tests run in the workshop root folder
cd "$(dirname "$0")"/..
export WORKSHOP_PATH="${PWD}"
export PATH="${WORKSHOP_PATH}/bin:${PATH}"
export FABRIC_CFG_PATH="${WORKSHOP_PATH}/config"
"${WORKSHOP_PATH}/check.sh"
CHAINCODE_PID=
function exitHook() {
# shut down the npm run
[ -n "${CHAINCODE_PID}" ] && kill "${CHAINCODE_PID}"
# Shut down microfab
docker kill microfab &> /dev/null
# Delete the network configuration and crypto material
rm -rf "${WORKSHOP_PATH}"/_cfg
}
trap exitHook SIGINT SIGTERM EXIT
just microfab
source "${WORKSHOP_PATH}/_cfg/uf/org1admin.env"
just debugcc
source "${WORKSHOP_PATH}/_cfg/uf/org1admin.env"
cd "${WORKSHOP_PATH}/contracts/asset-transfer-typescript"
npm install
npm run build
node_modules/.bin/fabric-chaincode-node server --chaincode-address="${CHAINCODE_SERVER_ADDRESS}" --chaincode-id="${CHAINCODE_ID}" &
CHAINCODE_PID=$!
sleep 5
cd "${WORKSHOP_PATH}/applications/trader-typescript"
export ENDPOINT=org1peer-api.127-0-0-1.nip.io:8080
export MSP_ID=org1MSP
export CERTIFICATE=../../_cfg/uf/_msp/org1/org1admin/msp/signcerts/cert.pem
export PRIVATE_KEY=../../_cfg/uf/_msp/org1/org1admin/msp/keystore/cert_sk
npm install
npm start getAllAssets
npm start transact
npm start getAllAssets
npm start create banana bananaman yellow
npm start read banana
npm start delete banana
SIMULATED_FAILURE_COUNT=2 npm start listen