1+ #! /usr/bin/env bash
2+
3+ #
4+ # Copyright IBM Corp. All Rights Reserved.
5+ #
6+ # SPDX-License-Identifier: Apache-2.0
7+ #
8+
9+ CONTAINER_CLI=" ${CONTAINER_CLI:- docker} "
10+
11+ # # Print a section title
12+ function print_section_header() {
13+ echo " # ========================="
14+ echo " # $1 "
15+ echo " # ========================="
16+ }
17+
18+ # # Cleanup and stop network on abort
19+ function cleanup() {
20+ stop_network
21+ exit 1
22+ }
23+
24+ # # Setup and start the network
25+ function run_network() {
26+ print_section_header " Setup and start the network..."
27+ make setup start
28+ }
29+
30+ # # Stop and clean up the network
31+ function stop_network() {
32+ print_section_header " Stopping network..."
33+ make teardown clean
34+ }
35+
36+ # # Initialize FabricX if needed
37+ function init_fabricx() {
38+ print_section_header " Initializing ${PLATFORM} ..."
39+ curl -f -X POST http://localhost:9300/endorser/init
40+ }
41+
42+ # # Run tests to verify the network
43+ function run_test() {
44+ # test application
45+ print_section_header " Run tests"
46+
47+ curl -f -X POST http://localhost:9100/issuer/issue -d ' {
48+ "amount": {"code": "TOK","value": 1000},
49+ "counterparty": {"node": "owner1","account": "alice"},
50+ "message": "hello world!"
51+ }'
52+ curl -f -X GET http://localhost:9500/owner/accounts/alice | jq
53+ curl -f -X GET http://localhost:9600/owner/accounts/dan | jq
54+ curl -f -X POST http://localhost:9500/owner/accounts/alice/transfer -d ' {
55+ "amount": {"code": "TOK","value": 100},
56+ "counterparty": {"node": "owner2","account": "dan"},
57+ "message": "hello dan!"
58+ }'
59+ curl -f -X GET http://localhost:9600/owner/accounts/dan/transactions | jq
60+ curl -f -X GET http://localhost:9500/owner/accounts/alice/transactions | jq
61+ }
62+
63+ # Script Start
64+ set +e
65+ set -o pipefail
66+ trap exit 1 INT
67+
68+ run_network
69+ # # currently we wait manually with a sleep.
70+ # # TODO: add an healthcheck within the `docker-compose`
71+ sleep 10
72+ if [[ " $PLATFORM " == " fabricx" ]]; then
73+ init_fabricx
74+ fi
75+ run_test
76+ stop_network
0 commit comments