-
Notifications
You must be signed in to change notification settings - Fork 3
/
execute.sh
executable file
·86 lines (66 loc) · 2.12 KB
/
execute.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: $0 [the language used to implement applications (node/java)]" >&2
exit 1
fi
LANG=$1
if [ "$LANG" = "node" ]; then
echo "The program is implemented with NodeJS"
elif [ "$LANG" = "java" ]; then
echo "The program is implemented with Java"
else
echo "Usage: $0 [node/java]" >&2
exit 1
fi
export ROOT=${PWD}
export NETWORK=${ROOT}/test-network
export APPLICATION=${ROOT}/application
export ANSWER=${ROOT}/answer
export ANSWER_FILE=${ANSWER}/answer
export FABRIC_CFG_PATH=${ROOT}/config
export IMAGE_TAG=2.1.0
export COMPOSE_PROJECT_NAME=snu
export PATH=$PATH:${PWD}/bin
# Configure the Network
echo "SNU Blockchain> Configure the test network"
./conf_network.sh
# Please Set the Chaincode to Peers, following the Lifecycle of the Chaincode
# Please refer to https://hyperledger-fabric.readthedocs.io/en/release-2.1/deploy_chaincode.html#package-the-smart-contract
# 1) TODO 1: Package the Chaincode
# 2) TODO 2: Install the Chaincode
# 3) TODO 3: Approve a Chaincode Definition
# 4) TODO 4: Committing the Chaincode Definition to the Channel
# TODO 5: Please Install any Dependencies and Generate Binaries of Client Applications (or Transactions), if needed
# ex) npm install or mvn clean package
# Test Clients and the Chaincode
# 1) Enroll the administrator
echo "SNU Blockchain> Enroll the administrator"
cd $APPLICATION
rm -rf $APPLICATION/wallet/*
if [ "$LANG" = "node" ]; then
test -f package-lock.json || npm install
node enrollAdmin.js
elif [ "$LANG" = "java" ]; then
java -jar EnrollAdmin.jar
fi
# 2) Register the appUser
echo "SNU Blockchain> Register the user"
cd $APPLICATION
if [ "$LANG" = "node" ]; then
node registerUser.js
elif [ "$LANG" = "java" ]; then
java -jar RegisterUser.jar
fi
# 3) Create the counters
echo "SNU Blockchain> Create the counters"
cd $ROOT
scripts/create.sh $LANG
# 4) Update the counters
echo "SNU Blockchain> Update the counters"
scripts/update.sh $LANG
# 5) Read the counters
echo "SNU Blockchain> Read the counters"
rm ${ANSWER_FILE}
scripts/read.sh $LANG > ${ANSWER_FILE}
echo "SNU Blockchain> Clean the test network"
./finish_network.sh