|
| 1 | +# This is a basic workflow to help you get started with Actions |
| 2 | + |
| 3 | +name: Asset Exchange Corda Tests |
| 4 | + |
| 5 | +# Controls when the workflow will run |
| 6 | +on: |
| 7 | + # Triggers the workflow on push or pull request events but only for the main branch |
| 8 | + push: |
| 9 | + branches: [ main ] |
| 10 | + pull_request: |
| 11 | + branches: [ main ] |
| 12 | + |
| 13 | + # Allows you to run this workflow manually from the Actions tab |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 17 | +jobs: |
| 18 | + |
| 19 | + asset-exchange-corda: |
| 20 | + # The type of runner that the job will run on |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 24 | + steps: |
| 25 | + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 26 | + - uses: actions/checkout@v2 |
| 27 | + |
| 28 | + - name: Set up JDK 8 |
| 29 | + uses: actions/setup-java@v2 |
| 30 | + with: |
| 31 | + java-version: '8' |
| 32 | + distribution: 'adopt' |
| 33 | + |
| 34 | + # CORDA NETWORK |
| 35 | + - name: Generate github.properties (on pull_request) |
| 36 | + if: ${{ github.event_name == 'pull_request' }} |
| 37 | + run: | |
| 38 | + echo "Using ${GITHUB_ACTOR} user." |
| 39 | + echo "username=${GITHUB_ACTOR}" >> github.properties |
| 40 | + echo "password=${{ secrets.GITHUB_TOKEN }}" >> github.properties |
| 41 | + echo "url=https://maven.pkg.github.com/${GITHUB_ACTOR}/weaver-dlt-interoperability" >> github.properties |
| 42 | + |
| 43 | + echo "Using ${GITHUB_ACTOR} user." |
| 44 | + echo "username=${GITHUB_ACTOR}" >> github.main.properties |
| 45 | + echo "password=${{ secrets.GITHUB_TOKEN }}" >> github.main.properties |
| 46 | + echo "url=https://maven.pkg.github.com/hyperledger-labs/weaver-dlt-interoperability" >> github.main.properties |
| 47 | + |
| 48 | + ./scripts/get-cordapps.sh || mv github.main.properties github.properties |
| 49 | + |
| 50 | + cat github.properties |
| 51 | + working-directory: tests/network-setups/corda |
| 52 | + |
| 53 | + - name: Generate github.properties (else) |
| 54 | + if: ${{ github.event_name != 'pull_request' }} |
| 55 | + run: | |
| 56 | + echo "Using ${GITHUB_ACTOR} user." |
| 57 | + echo "username=${GITHUB_ACTOR}" >> github.properties |
| 58 | + echo "password=${{ secrets.GITHUB_TOKEN }}" >> github.properties |
| 59 | + echo "url=https://maven.pkg.github.com/hyperledger-labs/weaver-dlt-interoperability" >> github.properties |
| 60 | + cat github.properties |
| 61 | + working-directory: tests/network-setups/corda |
| 62 | + |
| 63 | + # CORDA NETWORK |
| 64 | + - name: Start Corda Network |
| 65 | + run: | |
| 66 | + make start |
| 67 | + sleep 100 |
| 68 | + docker logs corda_partya_1 |
| 69 | + docker logs corda_partyb_1 |
| 70 | + working-directory: tests/network-setups/corda |
| 71 | + |
| 72 | + # FABRIC CLI |
| 73 | + - name: Setup Corda CLI init |
| 74 | + run: ./scripts/initAsset.sh |
| 75 | + working-directory: samples/corda/corda-simple-application |
| 76 | + |
| 77 | + - name: Asset Exchange Corda CLI Tests |
| 78 | + run: | |
| 79 | + COUNT=0 |
| 80 | + TOTAL=5 |
| 81 | +
|
| 82 | + # Lock 50 tokens |
| 83 | + 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 |
| 84 | + cat tmp.out | grep "HTLC Lock State created with contract ID Right" && COUNT=$(( COUNT + 1 )) && echo "PASS" |
| 85 | + cat tmp.out |
| 86 | + |
| 87 | + CID=$(cat tmp.out | grep "HTLC Lock State created with contract ID Right" | sed -e 's/.*Right(b=\(.*\))\./\1/') |
| 88 | + |
| 89 | + # Is Asset locked |
| 90 | + CORDA_PORT=10009 ./clients/build/install/clients/bin/clients is-asset-locked -cid $CID 1> tmp.out |
| 91 | + cat tmp.out | grep "Is Asset Locked Response: true" && COUNT=$(( COUNT + 1 )) && echo "PASS" |
| 92 | + cat tmp.out |
| 93 | + |
| 94 | + # Claim asset |
| 95 | + CORDA_PORT=10006 ./clients/build/install/clients/bin/clients claim-asset -cid $CID -s secrettext 1> tmp.out |
| 96 | + cat tmp.out | grep "Asset Claim Response: Right" && COUNT=$(( COUNT + 1 )) && echo "PASS" |
| 97 | + cat tmp.out |
| 98 | + |
| 99 | + # Timeout |
| 100 | + 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 |
| 101 | + CID=$(cat tmp.out | grep "HTLC Lock State created with contract ID Right" | sed -e 's/.*Right(b=\(.*\))\./\1/') |
| 102 | + sleep 5 |
| 103 | + cat tmp.out |
| 104 | + |
| 105 | + ## Is asset lock false |
| 106 | + CORDA_PORT=10009 ./clients/build/install/clients/bin/clients is-asset-locked -cid $CID 1> tmp.out |
| 107 | + cat tmp.out | grep "Is Asset Locked Response: false" && COUNT=$(( COUNT + 1 )) && echo "PASS" |
| 108 | + cat tmp.out |
| 109 | + |
| 110 | + ## Unlock asset |
| 111 | + CORDA_PORT=10006 ./clients/build/install/clients/bin/clients unlock-asset -cid $CID 1> tmp.out |
| 112 | + cat tmp.out | grep "Asset Unlock Response: Right" && COUNT=$(( COUNT + 1 )) && echo "PASS" |
| 113 | + cat tmp.out |
| 114 | +
|
| 115 | + # RESULT |
| 116 | + echo "Passed $COUNT/$TOTAL Tests." |
| 117 | +
|
| 118 | + if [ $COUNT == $TOTAL ]; then |
| 119 | + exit 0 |
| 120 | + else |
| 121 | + exit 1 |
| 122 | + fi |
| 123 | + working-directory: samples/corda/corda-simple-application |
| 124 | + |
| 125 | + asset-exchange-corda-local: |
| 126 | + # The type of runner that the job will run on |
| 127 | + runs-on: ubuntu-latest |
| 128 | + |
| 129 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 130 | + steps: |
| 131 | + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 132 | + - uses: actions/checkout@v2 |
| 133 | + |
| 134 | + - name: Set up JDK 8 |
| 135 | + uses: actions/setup-java@v2 |
| 136 | + with: |
| 137 | + java-version: '8' |
| 138 | + distribution: 'adopt' |
| 139 | + |
| 140 | + - name: Use Protoc 3.15 |
| 141 | + run: | |
| 142 | + curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.15.6/protoc-3.15.6-linux-x86_64.zip |
| 143 | + unzip protoc-3.15.6-linux-x86_64.zip -d protoc |
| 144 | + go get -u google.golang.org/protobuf/cmd/protoc-gen-go |
| 145 | + go get -u google.golang.org/grpc/cmd/protoc-gen-go-grpc |
| 146 | + |
| 147 | + - name: Build Java Protos |
| 148 | + run: make build |
| 149 | + working-directory: common/protos-java-kt |
| 150 | + |
| 151 | + # Build Dependencies |
| 152 | + - name: Build Corda Interop App |
| 153 | + run: make build-local |
| 154 | + working-directory: core/network/corda-interop-app |
| 155 | + |
| 156 | + - name: Build Corda Interop SDK |
| 157 | + run: make build |
| 158 | + working-directory: sdks/corda |
| 159 | + |
| 160 | + - name: Build Corda SimpleApplication |
| 161 | + run: make build-local |
| 162 | + working-directory: samples/corda/corda-simple-application |
| 163 | + |
| 164 | + # CORDA NETWORK |
| 165 | + - name: Start Corda Network |
| 166 | + run: | |
| 167 | + make start-local |
| 168 | + sleep 100 |
| 169 | + docker logs corda_partya_1 |
| 170 | + docker logs corda_partyb_1 |
| 171 | + working-directory: tests/network-setups/corda |
| 172 | + |
| 173 | + # FABRIC CLI |
| 174 | + - name: Setup Corda CLI init |
| 175 | + run: ./scripts/initAsset.sh |
| 176 | + working-directory: samples/corda/corda-simple-application |
| 177 | + |
| 178 | + - name: Asset Exchange Corda CLI Tests |
| 179 | + run: | |
| 180 | + COUNT=0 |
| 181 | + TOTAL=5 |
| 182 | +
|
| 183 | + # Lock 50 tokens |
| 184 | + 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 |
| 185 | + cat tmp.out | grep "HTLC Lock State created with contract ID Right" && COUNT=$(( COUNT + 1 )) && echo "PASS" |
| 186 | + cat tmp.out |
| 187 | + |
| 188 | + CID=$(cat tmp.out | grep "HTLC Lock State created with contract ID Right" | sed -e 's/.*Right(b=\(.*\))\./\1/') |
| 189 | + |
| 190 | + # Is Asset locked |
| 191 | + CORDA_PORT=10009 ./clients/build/install/clients/bin/clients is-asset-locked -cid $CID 1> tmp.out |
| 192 | + cat tmp.out | grep "Is Asset Locked Response: true" && COUNT=$(( COUNT + 1 )) && echo "PASS" |
| 193 | + cat tmp.out |
| 194 | + |
| 195 | + # Claim asset |
| 196 | + CORDA_PORT=10006 ./clients/build/install/clients/bin/clients claim-asset -cid $CID -s secrettext 1> tmp.out |
| 197 | + cat tmp.out | grep "Asset Claim Response: Right" && COUNT=$(( COUNT + 1 )) && echo "PASS" |
| 198 | + cat tmp.out |
| 199 | + |
| 200 | + # Timeout |
| 201 | + 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 |
| 202 | + CID=$(cat tmp.out | grep "HTLC Lock State created with contract ID Right" | sed -e 's/.*Right(b=\(.*\))\./\1/') |
| 203 | + sleep 5 |
| 204 | + cat tmp.out |
| 205 | + |
| 206 | + ## Is asset lock false |
| 207 | + CORDA_PORT=10009 ./clients/build/install/clients/bin/clients is-asset-locked -cid $CID 1> tmp.out |
| 208 | + cat tmp.out | grep "Is Asset Locked Response: false" && COUNT=$(( COUNT + 1 )) && echo "PASS" |
| 209 | + cat tmp.out |
| 210 | + |
| 211 | + ## Unlock asset |
| 212 | + CORDA_PORT=10006 ./clients/build/install/clients/bin/clients unlock-asset -cid $CID 1> tmp.out |
| 213 | + cat tmp.out | grep "Asset Unlock Response: Right" && COUNT=$(( COUNT + 1 )) && echo "PASS" |
| 214 | + cat tmp.out |
| 215 | +
|
| 216 | + # RESULT |
| 217 | + echo "Passed $COUNT/$TOTAL Tests." |
| 218 | +
|
| 219 | + if [ $COUNT == $TOTAL ]; then |
| 220 | + exit 0 |
| 221 | + else |
| 222 | + exit 1 |
| 223 | + fi |
| 224 | + working-directory: samples/corda/corda-simple-application |
| 225 | + |
| 226 | + house-token-exchange-corda: |
| 227 | + # The type of runner that the job will run on |
| 228 | + runs-on: ubuntu-latest |
| 229 | + |
| 230 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 231 | + steps: |
| 232 | + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 233 | + - uses: actions/checkout@v2 |
| 234 | + |
| 235 | + - name: Set up JDK 8 |
| 236 | + uses: actions/setup-java@v2 |
| 237 | + with: |
| 238 | + java-version: '8' |
| 239 | + distribution: 'adopt' |
| 240 | + |
| 241 | + # CORDA NETWORK |
| 242 | + - name: Generate github.properties (on pull_request) |
| 243 | + if: ${{ github.event_name == 'pull_request' }} |
| 244 | + run: | |
| 245 | + echo "Using ${GITHUB_ACTOR} user." |
| 246 | + echo "username=${GITHUB_ACTOR}" >> github.properties |
| 247 | + echo "password=${{ secrets.GITHUB_TOKEN }}" >> github.properties |
| 248 | + echo "url=https://maven.pkg.github.com/${GITHUB_ACTOR}/weaver-dlt-interoperability" >> github.properties |
| 249 | + |
| 250 | + echo "Using ${GITHUB_ACTOR} user." |
| 251 | + echo "username=${GITHUB_ACTOR}" >> github.main.properties |
| 252 | + echo "password=${{ secrets.GITHUB_TOKEN }}" >> github.main.properties |
| 253 | + echo "url=https://maven.pkg.github.com/hyperledger-labs/weaver-dlt-interoperability" >> github.main.properties |
| 254 | + |
| 255 | + ./scripts/get-cordapps.sh || mv github.main.properties github.properties |
| 256 | + |
| 257 | + cat github.properties |
| 258 | + working-directory: tests/network-setups/corda |
| 259 | + |
| 260 | + - name: Generate github.properties (else) |
| 261 | + if: ${{ github.event_name != 'pull_request' }} |
| 262 | + run: | |
| 263 | + echo "Using ${GITHUB_ACTOR} user." |
| 264 | + echo "username=${GITHUB_ACTOR}" >> github.properties |
| 265 | + echo "password=${{ secrets.GITHUB_TOKEN }}" >> github.properties |
| 266 | + echo "url=https://maven.pkg.github.com/hyperledger-labs/weaver-dlt-interoperability" >> github.properties |
| 267 | + cat github.properties |
| 268 | + working-directory: tests/network-setups/corda |
| 269 | + |
| 270 | + # CORDA NETWORK |
| 271 | + - name: Start Corda Network |
| 272 | + run: | |
| 273 | + make start-house |
| 274 | + sleep 100 |
| 275 | + docker logs corda_partya_1 |
| 276 | + docker logs corda_partyb_1 |
| 277 | + docker logs corda_partyc_1 |
| 278 | + working-directory: tests/network-setups/corda |
| 279 | + |
| 280 | + # FABRIC CLI |
| 281 | + - name: Setup Corda CLI init |
| 282 | + run: ./scripts/initHouseToken.sh |
| 283 | + working-directory: samples/corda/corda-simple-application |
| 284 | + |
| 285 | + - name: House Token Exchange Corda CLI Tests |
| 286 | + run: | |
| 287 | + COUNT=0 |
| 288 | + TOTAL=5 |
| 289 | +
|
| 290 | + # Lock 50 tokens |
| 291 | + 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 |
| 292 | + cat tmp.out | grep "HTLC Lock State created with contract ID Right" && COUNT=$(( COUNT + 1 )) && echo "PASS" |
| 293 | + cat tmp.out |
| 294 | + |
| 295 | + CID=$(cat tmp.out | grep "HTLC Lock State created with contract ID Right" | sed -e 's/.*Right(b=\(.*\))\./\1/') |
| 296 | + |
| 297 | + # Is Asset locked |
| 298 | + CORDA_PORT=10009 ./clients/build/install/clients/bin/clients house-token is-locked -cid $CID 1> tmp.out |
| 299 | + cat tmp.out | grep "Is Asset Locked Response: true" && COUNT=$(( COUNT + 1 )) && echo "PASS" |
| 300 | + cat tmp.out |
| 301 | + |
| 302 | + # Claim asset |
| 303 | + CORDA_PORT=10006 ./clients/build/install/clients/bin/clients house-token claim -cid $CID -s secrettext 1> tmp.out |
| 304 | + cat tmp.out | grep "Asset Claim Response: Right" && COUNT=$(( COUNT + 1 )) && echo "PASS" |
| 305 | + cat tmp.out |
| 306 | + |
| 307 | + # Timeout |
| 308 | + CORDA_PORT=10006 ./clients/build/install/clients/bin/clients house-token lock -f -h64 ivHErp1x4bJDKuRo6L5bApO/DdoyD/dG0mAZrzLZEIs= -t 5 -r "O=PartyB,L=London,C=GB" -p house:20 1> tmp.out |
| 309 | + CID=$(cat tmp.out | grep "HTLC Lock State created with contract ID Right" | sed -e 's/.*Right(b=\(.*\))\./\1/') |
| 310 | + sleep 5 |
| 311 | + cat tmp.out |
| 312 | + |
| 313 | + ## Is asset lock false |
| 314 | + CORDA_PORT=10009 ./clients/build/install/clients/bin/clients house-token is-locked -cid $CID 1> tmp.out |
| 315 | + cat tmp.out | grep "Is Asset Locked Response: false" && COUNT=$(( COUNT + 1 )) && echo "PASS" |
| 316 | + cat tmp.out |
| 317 | + |
| 318 | + ## Unlock asset |
| 319 | + CORDA_PORT=10006 ./clients/build/install/clients/bin/clients house-token unlock -cid $CID 1> tmp.out |
| 320 | + cat tmp.out | grep "Asset Unlock Response: Right" && COUNT=$(( COUNT + 1 )) && echo "PASS" |
| 321 | + cat tmp.out |
| 322 | +
|
| 323 | + # RESULT |
| 324 | + echo "Passed $COUNT/$TOTAL Tests." |
| 325 | +
|
| 326 | + if [ $COUNT == $TOTAL ]; then |
| 327 | + exit 0 |
| 328 | + else |
| 329 | + exit 1 |
| 330 | + fi |
| 331 | + working-directory: samples/corda/corda-simple-application |
0 commit comments