diff --git a/ci/scripts/run-test-network-off-chain.sh b/ci/scripts/run-test-network-off-chain.sh index 872cda41..dc7bfc1e 100755 --- a/ci/scripts/run-test-network-off-chain.sh +++ b/ci/scripts/run-test-network-off-chain.sh @@ -41,11 +41,22 @@ print "Initializing Typescript off-chain data application" pushd ../off_chain_data/application-typescript rm -f checkpoint.json store.log npm install -print "Running the output app" +print "Running the Typescript app" SIMULATED_FAILURE_COUNT=1 npm start getAllAssets transact getAllAssets listen SIMULATED_FAILURE_COUNT=1 npm start listen popd +# Run off-chain data Go application +export CHAINCODE_NAME=go_off_chain_data +deployChaincode +print "Initializing Go off-chain data application" +pushd ../off_chain_data/application-go +rm -f checkpoint.json store.log +print "Running the Go app" +SIMULATED_FAILURE_COUNT=1 go run . getAllAssets transact getAllAssets listen +SIMULATED_FAILURE_COUNT=1 go run . listen +popd + # Run off-chain data Java application #createNetwork export CHAINCODE_NAME=off_chain_data diff --git a/off_chain_data/README.md b/off_chain_data/README.md index a78b84b0..22e1948f 100644 --- a/off_chain_data/README.md +++ b/off_chain_data/README.md @@ -65,6 +65,10 @@ The Fabric test network is used to deploy and run this sample. Follow these step npm install npm start transact listen + # To run the Go sample application + cd application-go + go run . transact listen + # To run the Java sample application cd application-java ./gradlew run --quiet --args='transact listen' @@ -79,6 +83,10 @@ The Fabric test network is used to deploy and run this sample. Follow these step cd application-typescript npm --silent start getAllAssets + # To run the Go sample application + cd application-go + go run . getAllAssets + # To run the Java sample application cd application-java ./gradlew run --quiet --args=getAllAssets @@ -93,6 +101,12 @@ The Fabric test network is used to deploy and run this sample. Follow these step SIMULATED_FAILURE_COUNT=5 npm start listen npm start listen + # To run the Go sample application + cd application-go + go run . transact + SIMULATED_FAILURE_COUNT=5 go run . listen + go run . listen + # To run the Java sample application cd application-java ./gradlew run --quiet --args=transact diff --git a/off_chain_data/application-go/getAllAssets.go b/off_chain_data/application-go/getAllAssets.go index c9cca4da..c2ccf2c7 100644 --- a/off_chain_data/application-go/getAllAssets.go +++ b/off_chain_data/application-go/getAllAssets.go @@ -20,7 +20,7 @@ func getAllAssets(clientConnection *grpc.ClientConn) { id, options := newConnectOptions(clientConnection) gateway, err := client.Connect(id, options...) if err != nil { - panic((err)) + panic(err) } defer gateway.Close() @@ -28,7 +28,12 @@ func getAllAssets(clientConnection *grpc.ClientConn) { smartContract := atb.NewAssetTransferBasic(contract) assets, err := smartContract.GetAllAssets() if err != nil { - panic((err)) + panic(err) + } + + if len(assets) == 0 { + fmt.Println("no assets") + return } fmt.Println(formatJSON(assets))