mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
This patch updates CI pipeline scripts which utilizes global shared library reusable functions. It also creates ci.properties file with all the parameters required to test the fabric-samples patch. Change-Id: Ib2fd948eae9f2e37535144489279773836400358 Signed-off-by: rameshthoomu <rameshbabu.thoomu@gmail.com>
109 lines
4.3 KiB
Bash
Executable file
109 lines
4.3 KiB
Bash
Executable file
#!/bin/bash
|
|
#
|
|
# Copyright IBM Corp All Rights Reserved
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
# Exit on first error
|
|
set -e
|
|
|
|
# don't rewrite paths for Windows Git Bash users
|
|
export MSYS_NO_PATHCONV=1
|
|
starttime=$(date +%s)
|
|
CC_SRC_LANGUAGE=${1:-"go"}
|
|
CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]`
|
|
if [ "$CC_SRC_LANGUAGE" = "go" -o "$CC_SRC_LANGUAGE" = "golang" ]; then
|
|
CC_RUNTIME_LANGUAGE=golang
|
|
CC_SRC_PATH=github.com/fabcar/go
|
|
elif [ "$CC_SRC_LANGUAGE" = "javascript" ]; then
|
|
CC_RUNTIME_LANGUAGE=node # chaincode runtime language is node.js
|
|
CC_SRC_PATH=/opt/gopath/src/github.com/fabcar/javascript
|
|
elif [ "$CC_SRC_LANGUAGE" = "typescript" ]; then
|
|
CC_RUNTIME_LANGUAGE=node # chaincode runtime language is node.js
|
|
CC_SRC_PATH=/opt/gopath/src/github.com/fabcar/typescript
|
|
echo Compiling TypeScript code into JavaScript ...
|
|
pushd ../chaincode/fabcar/typescript
|
|
npm install
|
|
npm run build
|
|
popd
|
|
echo Finished compiling TypeScript code into JavaScript
|
|
else
|
|
echo The chaincode language ${CC_SRC_LANGUAGE} is not supported by this script
|
|
echo Supported chaincode languages are: go, javascript, and typescript
|
|
exit 1
|
|
fi
|
|
|
|
|
|
# clean the keystore
|
|
rm -rf ./hfc-key-store
|
|
|
|
# launch network; create channel and join peer to channel
|
|
cd ../basic-network
|
|
./start.sh
|
|
|
|
# Now launch the CLI container in order to install, instantiate chaincode
|
|
# and prime the ledger with our 10 cars
|
|
docker-compose -f ./docker-compose.yml up -d cli
|
|
docker ps -a
|
|
|
|
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp" cli peer chaincode install -n fabcar -v 1.0 -p "$CC_SRC_PATH" -l "$CC_RUNTIME_LANGUAGE"
|
|
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp" cli peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n fabcar -l "$CC_RUNTIME_LANGUAGE" -v 1.0 -c '{"Args":[]}' -P "OR ('Org1MSP.member','Org2MSP.member')"
|
|
sleep 10
|
|
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp" cli peer chaincode invoke -o orderer.example.com:7050 -C mychannel -n fabcar -c '{"function":"initLedger","Args":[]}'
|
|
|
|
cat <<EOF
|
|
|
|
Total setup execution time : $(($(date +%s) - starttime)) secs ...
|
|
|
|
Next, use the FabCar applications to interact with the deployed FabCar contract.
|
|
The FabCar applications are available in multiple programming languages.
|
|
Follow the instructions for the programming language of your choice:
|
|
|
|
JavaScript:
|
|
|
|
Start by changing into the "javascript" directory:
|
|
cd javascript
|
|
|
|
Next, install all required packages:
|
|
npm install
|
|
|
|
Then run the following applications to enroll the admin user, and register a new user
|
|
called user1 which will be used by the other applications to interact with the deployed
|
|
FabCar contract:
|
|
node enrollAdmin
|
|
node registerUser
|
|
|
|
You can run the invoke application as follows. By default, the invoke application will
|
|
create a new car, but you can update the application to submit other transactions:
|
|
node invoke
|
|
|
|
You can run the query application as follows. By default, the query application will
|
|
return all cars, but you can update the application to evaluate other transactions:
|
|
node query
|
|
|
|
TypeScript:
|
|
|
|
Start by changing into the "typescript" directory:
|
|
cd typescript
|
|
|
|
Next, install all required packages:
|
|
npm install
|
|
|
|
Next, compile the TypeScript code into JavaScript:
|
|
npm run build
|
|
|
|
Then run the following applications to enroll the admin user, and register a new user
|
|
called user1 which will be used by the other applications to interact with the deployed
|
|
FabCar contract:
|
|
node dist/enrollAdmin
|
|
node dist/registerUser
|
|
|
|
You can run the invoke application as follows. By default, the invoke application will
|
|
create a new car, but you can update the application to submit other transactions:
|
|
node dist/invoke
|
|
|
|
You can run the query application as follows. By default, the query application will
|
|
return all cars, but you can update the application to evaluate other transactions:
|
|
node dist/query
|
|
|
|
EOF
|