-
Notifications
You must be signed in to change notification settings - Fork 45
312 lines (249 loc) · 12.6 KB
/
test_asset-exchange-corda.yml
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: CC-BY-4.0
# This is a basic workflow to help you get started with Actions
name: Test Asset Exchange Corda
# 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:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
asset-exchange-corda:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
# CORDA NETWORK
- name: Generate github.properties
run: |
echo "Using ${GITHUB_ACTOR} user."
echo "username=${GITHUB_ACTOR}" >> github.properties
echo "password=${{ secrets.GITHUB_TOKEN }}" >> github.properties
echo "url=https://maven.pkg.github.com/${GITHUB_ACTOR}/weaver-dlt-interoperability" >> github.properties
echo "Using ${GITHUB_ACTOR} user."
echo "username=${GITHUB_ACTOR}" >> github.main.properties
echo "password=${{ secrets.GITHUB_TOKEN }}" >> github.main.properties
echo "url=https://maven.pkg.github.com/hyperledger-labs/weaver-dlt-interoperability" >> github.main.properties
./scripts/get-cordapps.sh || mv github.main.properties github.properties
cat github.properties
working-directory: tests/network-setups/corda
# CORDA NETWORK
- name: Start Corda Network
run: |
make start-network1 PROFILE=3-nodes
sleep 100
docker logs corda_partya_1
docker logs corda_partyb_1
working-directory: tests/network-setups/corda
# FABRIC CLI
- name: Setup Corda CLI init
run: ./scripts/initAsset.sh 1
working-directory: samples/corda/corda-simple-application
- name: Asset Exchange Corda CLI Tests
run: |
COUNT=0
TOTAL=5
# Lock 50 tokens
CORDA_PORT=10009 ./clients/build/install/clients/bin/clients lock-asset -f -h64 ivHErp1x4bJDKuRo6L5bApO/DdoyD/dG0mAZrzLZEIs= -t 180 -r "O=PartyA,L=London,C=GB" -p t1:50 1> tmp.out
cat tmp.out | grep "HTLC Lock State created with contract ID Right" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
CID=$(cat tmp.out | grep "HTLC Lock State created with contract ID Right" | sed -e 's/.*Right(b=\(.*\))\./\1/')
# Is Asset locked
CORDA_PORT=10009 ./clients/build/install/clients/bin/clients is-asset-locked -cid $CID 1> tmp.out
cat tmp.out | grep "Is Asset Locked Response: true" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
# Claim asset
CORDA_PORT=10006 ./clients/build/install/clients/bin/clients claim-asset -cid $CID -s secrettext 1> tmp.out
cat tmp.out | grep "Asset Claim Response: Right" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
# Timeout
CORDA_PORT=10006 ./clients/build/install/clients/bin/clients lock-asset -f -h64 ivHErp1x4bJDKuRo6L5bApO/DdoyD/dG0mAZrzLZEIs= -t 5 -r "O=PartyB,L=London,C=GB" -p t1:50 1> tmp.out
CID=$(cat tmp.out | grep "HTLC Lock State created with contract ID Right" | sed -e 's/.*Right(b=\(.*\))\./\1/')
sleep 5
cat tmp.out
## Is asset lock false
CORDA_PORT=10009 ./clients/build/install/clients/bin/clients is-asset-locked -cid $CID 1> tmp.out
cat tmp.out | grep "Is Asset Locked Response: false" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
## Unlock asset
CORDA_PORT=10006 ./clients/build/install/clients/bin/clients unlock-asset -cid $CID 1> tmp.out
cat tmp.out | grep "Asset Unlock Response: Right" && 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: samples/corda/corda-simple-application
asset-exchange-corda-local:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
- name: Build Java Protos
run: make build
working-directory: common/protos-java-kt
# Build Dependencies
- name: Build Corda Interop App
run: make build-local
working-directory: core/network/corda-interop-app
- name: Build Corda Interop SDK
run: make build
working-directory: sdks/corda
- name: Build Corda SimpleApplication
run: make build-local
working-directory: samples/corda/corda-simple-application
# CORDA NETWORK
- name: Start Corda Network
run: |
make start-network1-local PROFILE=3-nodes
sleep 100
docker logs corda_partya_1
docker logs corda_partyb_1
working-directory: tests/network-setups/corda
# FABRIC CLI
- name: Setup Corda CLI init
run: ./scripts/initAsset.sh 1
working-directory: samples/corda/corda-simple-application
- name: Asset Exchange Corda CLI Tests
run: |
COUNT=0
TOTAL=5
# Lock 50 tokens
CORDA_PORT=10009 ./clients/build/install/clients/bin/clients lock-asset -f -h64 ivHErp1x4bJDKuRo6L5bApO/DdoyD/dG0mAZrzLZEIs= -t 180 -r "O=PartyA,L=London,C=GB" -p t1:50 1> tmp.out
cat tmp.out | grep "HTLC Lock State created with contract ID Right" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
CID=$(cat tmp.out | grep "HTLC Lock State created with contract ID Right" | sed -e 's/.*Right(b=\(.*\))\./\1/')
# Is Asset locked
CORDA_PORT=10009 ./clients/build/install/clients/bin/clients is-asset-locked -cid $CID 1> tmp.out
cat tmp.out | grep "Is Asset Locked Response: true" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
# Claim asset
CORDA_PORT=10006 ./clients/build/install/clients/bin/clients claim-asset -cid $CID -s secrettext 1> tmp.out
cat tmp.out | grep "Asset Claim Response: Right" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
# Timeout
CORDA_PORT=10006 ./clients/build/install/clients/bin/clients lock-asset -f -h64 ivHErp1x4bJDKuRo6L5bApO/DdoyD/dG0mAZrzLZEIs= -t 5 -r "O=PartyB,L=London,C=GB" -p t1:50 1> tmp.out
CID=$(cat tmp.out | grep "HTLC Lock State created with contract ID Right" | sed -e 's/.*Right(b=\(.*\))\./\1/')
sleep 5
cat tmp.out
## Is asset lock false
CORDA_PORT=10009 ./clients/build/install/clients/bin/clients is-asset-locked -cid $CID 1> tmp.out
cat tmp.out | grep "Is Asset Locked Response: false" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
## Unlock asset
CORDA_PORT=10006 ./clients/build/install/clients/bin/clients unlock-asset -cid $CID 1> tmp.out
cat tmp.out | grep "Asset Unlock Response: Right" && 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: samples/corda/corda-simple-application
house-token-exchange-corda:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
# CORDA NETWORK
- name: Generate github.properties
run: |
echo "Using ${GITHUB_ACTOR} user."
echo "username=${GITHUB_ACTOR}" >> github.properties
echo "password=${{ secrets.GITHUB_TOKEN }}" >> github.properties
echo "url=https://maven.pkg.github.com/${GITHUB_ACTOR}/weaver-dlt-interoperability" >> github.properties
echo "Using ${GITHUB_ACTOR} user."
echo "username=${GITHUB_ACTOR}" >> github.main.properties
echo "password=${{ secrets.GITHUB_TOKEN }}" >> github.main.properties
echo "url=https://maven.pkg.github.com/hyperledger-labs/weaver-dlt-interoperability" >> github.main.properties
./scripts/get-cordapps.sh || mv github.main.properties github.properties
cat github.properties
working-directory: tests/network-setups/corda
# CORDA NETWORK
- name: Start Corda Network
run: |
make start-network1 APP_NAME=house PROFILE=3-nodes
sleep 100
docker logs corda_partya_1
docker logs corda_partyb_1
docker logs corda_partyc_1
working-directory: tests/network-setups/corda
# CORDA CLI
- name: Build CLI
run: |
cp ../../../tests/network-setups/corda/github.properties .
make build-cli
working-directory: samples/corda/corda-simple-application
- name: Setup Corda CLI init
run: ./scripts/initHouseToken.sh 1
working-directory: samples/corda/corda-simple-application
- name: House Token Exchange Corda CLI Tests
run: |
COUNT=0
TOTAL=5
# Lock 50 tokens
CORDA_PORT=10009 ./clients/build/install/clients/bin/clients house-token lock -f -h64 ivHErp1x4bJDKuRo6L5bApO/DdoyD/dG0mAZrzLZEIs= -t 180 -r "O=PartyA,L=London,C=GB" -o "O=PartyC,L=London,C=GB" -p house:10 1> tmp.out
cat tmp.out | grep "HTLC Lock State created with contract ID Right" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
CID=$(cat tmp.out | grep "HTLC Lock State created with contract ID Right" | sed -e 's/.*Right(b=\(.*\))\./\1/')
# Is Asset locked
CORDA_PORT=10009 ./clients/build/install/clients/bin/clients house-token is-locked -cid $CID 1> tmp.out
cat tmp.out | grep "Is Asset Locked Response: true" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
# Claim asset
CORDA_PORT=10006 ./clients/build/install/clients/bin/clients house-token claim -cid $CID -s secrettext 1> tmp.out
cat tmp.out | grep "Asset Claim Response: Right" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
# Timeout
CORDA_PORT=10006 ./clients/build/install/clients/bin/clients house-token lock -f -h64 ivHErp1x4bJDKuRo6L5bApO/DdoyD/dG0mAZrzLZEIs= -t 10 -r "O=PartyB,L=London,C=GB" -p house:20 1> tmp.out
CID=$(cat tmp.out | grep "HTLC Lock State created with contract ID Right" | sed -e 's/.*Right(b=\(.*\))\./\1/')
sleep 10
cat tmp.out
## Is asset lock false
CORDA_PORT=10009 ./clients/build/install/clients/bin/clients house-token is-locked -cid $CID 1> tmp.out
cat tmp.out | grep "Is Asset Locked Response: false" && COUNT=$(( COUNT + 1 )) && echo "PASS"
cat tmp.out
## Unlock asset
CORDA_PORT=10006 ./clients/build/install/clients/bin/clients house-token unlock -cid $CID 1> tmp.out
cat tmp.out | grep "Asset Unlock Response: Right" && 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: samples/corda/corda-simple-application