-
Notifications
You must be signed in to change notification settings - Fork 286
206 lines (171 loc) · 7.16 KB
/
test_weaver-fabric-fabric-satp.yaml
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: CC-BY-4.0
name: Secure Test Asset Transfer
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
check_code_changed:
outputs:
status: ${{ steps.changes.outputs.weaver_code_changed }}
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: dorny/[email protected]
id: changes
with:
filters: |
weaver_code_changed:
- './weaver/**'
- '.github/workflows/test_weaver-fabric-fabric-satp.yaml'
fabric-fabric-satp-local:
needs: check_code_changed
if: ${{ false && needs.check_code_changed.outputs.status == 'true' }}
# if: ${{ false }}
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/[email protected]
- name: Set up JDK 8
uses: actions/[email protected]
with:
java-version: '8'
distribution: 'adopt'
- name: Set up Go
uses: actions/[email protected]
with:
go-version: '1.20.2'
- name: Use Node.js 16.x
uses: actions/[email protected]
with:
node-version: 16.x
- name: Install RUST Toolchain minimal stable with clippy and rustfmt
uses: actions-rs/[email protected]
with:
profile: minimal
toolchain: stable
components: rustfmt, clippy
- name: Get Latest Relay Dependencies
run: |
make protos-local
cargo update -p nom
cargo update -p lexical-core
working-directory: weaver/core/relay
- name: Use Protoc 3.15
run: |
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.15.6/protoc-3.15.6-linux-x86_64.zip
unzip protoc-3.15.6-linux-x86_64.zip -d protoc
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
# PROTOS GO
- name: Build GO Protos
run: |
export PATH="$PATH:${GITHUB_WORKSPACE}/protoc/bin"
make build
working-directory: weaver/common/protos-go
# PROTOS JS
- name: Build JS Protos
run: |
export PATH="$PATH:${GITHUB_WORKSPACE}/protoc/bin"
make build
working-directory: weaver/common/protos-js
# Build Dependencies
- name: Build Fabric Interop SDK
run: make build-local
working-directory: weaver/sdks/fabric/interoperation-node-sdk
- name: Build Fabric CLI
run: make build-local
working-directory: weaver/samples/fabric/fabric-cli
- name: Build Relay
run: make
working-directory: weaver/core/relay
- name: Build Fabric Driver
run: make build-local
working-directory: weaver/core/drivers/fabric-driver
# FABRIC NETWORK
- name: Start Fabric Network
run: make start-interop-local CHAINCODE_NAME=satpsimpleasset
working-directory: weaver/tests/network-setups/fabric/dev
# GATEWAY
- name: Start Relay for network1 and network2
run: RELAY_CONFIG=config/Dummy_Relay.toml cargo run --bin server &> gateway.out &
working-directory: weaver/core/relay
# FABRIC DRIVER
- name: Setup Fabric Driver .env
run: |
cp .env.satp.template .env
sed -i "s#<PATH-TO-WEAVER>#${GITHUB_WORKSPACE}/weaver#g" .env
working-directory: weaver/core/drivers/fabric-driver
- name: Start Fabric Driver for network1 and network2
run: npm run dev &> fdriver.out &
working-directory: weaver/core/drivers/fabric-driver
# FABRIC CLI
- name: Setup Fabric CLI ENV
run: |
echo ${GITHUB_WORKSPACE}
cp .env.template .env
./bin/fabric-cli env set-file ./.env
./bin/fabric-cli env set MEMBER_CREDENTIAL_FOLDER ${GITHUB_WORKSPACE}/weaver/samples/fabric/fabric-cli/src/data/credentials
./bin/fabric-cli env set CONFIG_PATH ${GITHUB_WORKSPACE}/weaver/samples/fabric/fabric-cli/config.json
./bin/fabric-cli env set DEFAULT_APPLICATION_CHAINCODE satpsimpleasset
./bin/fabric-cli env set REMOTE_CONFIG_PATH ${GITHUB_WORKSPACE}/weaver/samples/fabric/fabric-cli/remote-network-config.json
./bin/fabric-cli env set CHAINCODE_PATH ${GITHUB_WORKSPACE}/weaver/samples/fabric/fabric-cli/chaincode.json
cat .env
working-directory: weaver/samples/fabric/fabric-cli
- name: Setup Fabric CLI Config
run: |
echo ${GITHUB_WORKSPACE}
cp config.satp.template.json config.json
sed -i "s#<PATH-TO-WEAVER>#${GITHUB_WORKSPACE}/weaver#g" config.json
###### Change line number in following commands if config is modified #####
./bin/fabric-cli config set network2 aclPolicyPrincipalType ca
./bin/fabric-cli config set network1 chaincode satpsimpleasset
./bin/fabric-cli config set network2 chaincode satpsimpleasset
cp chaincode.json.template chaincode.json
cp remote-network-config.json.template remote-network-config.json
working-directory: weaver/samples/fabric/fabric-cli
- name: Fabric CLI Init
run: |
./bin/fabric-cli configure create all --local-network=network1
./bin/fabric-cli configure create all --local-network=network2
./bin/fabric-cli configure network --local-network=network1
./bin/fabric-cli configure network --local-network=network2
./scripts/initAsset.sh
working-directory: weaver/samples/fabric/fabric-cli
# CLIENT
- name: Start the client to initiate the satp protocol
run: cargo run --bin satp_client "9085" "localhost:9085/Dummy_Network/abc:abc:abc:abc"
working-directory: weaver/core/relay
# Test SATP
- name: Test SATP
run: |
COUNT=0
TOTAL=1
./bin/fabric-cli chaincode query --user=bob mychannel satpsimpleasset ReadAsset '["bond01","a04"]' --local-network=network1 &> tmp.out
cat tmp.out | tr '\n' ' ' | grep "Result from network query: { \"type\": \"bond01\", \"id\": \"a04\"" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
# RESULT
echo "Passed $COUNT/$TOTAL Tests."
if [ $COUNT == $TOTAL ]; then
exit 0
else
exit 1
fi
working-directory: weaver/samples/fabric/fabric-cli
- name: DEBUG Logs - fabric n1 and n2 gateway
if: failure()
run: cat weaver/core/relay/gateway.out
- name: DEBUG Logs - fabric n1 and n2 driver
if: failure()
run: cat weaver/core/drivers/fabric-driver/fdriver.out