Skip to content

Commit

Permalink
Add test-network sample test
Browse files Browse the repository at this point in the history
Signed-off-by: Marcus Brandenburger <[email protected]>
  • Loading branch information
mbrandenburger committed Jul 26, 2024
1 parent f71dd8e commit 2a3ee9c
Show file tree
Hide file tree
Showing 9 changed files with 218 additions and 63 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/hyperledger/fabric-contract-api-go v1.2.1
github.com/hyperledger/fabric-protos-go v0.3.0
github.com/hyperledger/fabric-samples/asset-transfer-basic/chaincode-go v0.0.0-20230505123407-84f9ba1dc4ec
github.com/hyperledger/fabric-sdk-go v1.0.1-0.20221020141211-7af45cede6af
github.com/hyperledger/fabric-sdk-go v1.0.1-0.20240123083657-5d6ca326e01b
github.com/maxbrunsfeld/counterfeiter/v6 v6.6.1
github.com/onsi/ginkgo v1.16.5
github.com/onsi/ginkgo/v2 v2.11.0
Expand Down
12 changes: 12 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,18 @@ github.com/hyperledger/fabric-contract-api-go v1.2.1/go.mod h1:BhWve0gz1iH+Xc+cO
github.com/hyperledger/fabric-lib-go v1.0.0 h1:UL1w7c9LvHZUSkIvHTDGklxFv2kTeva1QI2emOVc324=
github.com/hyperledger/fabric-lib-go v1.0.0/go.mod h1:H362nMlunurmHwkYqR5uHL2UDWbQdbfz74n8kbCFsqc=
github.com/hyperledger/fabric-protos-go v0.0.0-20200424173316-dd554ba3746e/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0=
github.com/hyperledger/fabric-protos-go v0.0.0-20200707132912-fee30f3ccd23/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0=
github.com/hyperledger/fabric-protos-go v0.0.0-20211118165945-23d738fc3553/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0=
github.com/hyperledger/fabric-protos-go v0.3.0 h1:MXxy44WTMENOh5TI8+PCK2x6pMj47Go2vFRKDHB2PZs=
github.com/hyperledger/fabric-protos-go v0.3.0/go.mod h1:WWnyWP40P2roPmmvxsUXSvVI/CF6vwY1K1UFidnKBys=
github.com/hyperledger/fabric-samples/asset-transfer-basic/chaincode-go v0.0.0-20230505123407-84f9ba1dc4ec h1:drq6iuHjLc3H41zGfvljRZky45aLsWfc/J/lc52KjLY=
github.com/hyperledger/fabric-samples/asset-transfer-basic/chaincode-go v0.0.0-20230505123407-84f9ba1dc4ec/go.mod h1:Y4ClFGIk5nmTlFOtryAY+sC55tYCpA6YZItPaKwPY6s=
github.com/hyperledger/fabric-sdk-go v1.0.0 h1:NRu0iNbHV6u4nd9jgYghAdA1Ll4g0Sri4hwMEGiTbyg=
github.com/hyperledger/fabric-sdk-go v1.0.0/go.mod h1:qWE9Syfg1KbwNjtILk70bJLilnmCvllIYFCSY/pa1RU=
github.com/hyperledger/fabric-sdk-go v1.0.1-0.20221020141211-7af45cede6af h1:/DGxnlhN6Cg1PKj/5K01GUt4X1wN8nRVkZiJiQ05sCw=
github.com/hyperledger/fabric-sdk-go v1.0.1-0.20221020141211-7af45cede6af/go.mod h1:JRplpKBeAvXjsBhOCCM/KvMRUbdDyhsAh80qbXzKc10=
github.com/hyperledger/fabric-sdk-go v1.0.1-0.20240123083657-5d6ca326e01b h1:ioSmXcO2r9+Sf7QbeaCQkWuTy5uHd+4u5CtFKLJhvRU=
github.com/hyperledger/fabric-sdk-go v1.0.1-0.20240123083657-5d6ca326e01b/go.mod h1:JRplpKBeAvXjsBhOCCM/KvMRUbdDyhsAh80qbXzKc10=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
Expand Down Expand Up @@ -314,6 +319,7 @@ github.com/lib/pq v0.0.0-20180201184707-88edab080323/go.mod h1:5WUZQaWbwv1U+lTRe
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
Expand Down Expand Up @@ -413,6 +419,7 @@ github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIw
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml v1.8.0/go.mod h1:D6yutnOGMveHEPV7VQOuvI/gXY61bv+9bAOTRnLElKs=
github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
Expand All @@ -432,6 +439,7 @@ github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndr
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g=
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q=
github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY=
Expand All @@ -444,12 +452,14 @@ github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cY
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc=
github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA=
github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY=
github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
Expand Down Expand Up @@ -479,6 +489,7 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/afero v1.3.1/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4=
github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY=
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
Expand Down Expand Up @@ -644,6 +655,7 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190515120540-06a5c4944438/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
38 changes: 12 additions & 26 deletions samples/deployment/test-network/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,7 @@
TOP = ../../..
include $(TOP)/build.mk

ifeq ($(CC_ID),)
$(error CC_ID is not set)
endif
ifeq ($(CC_PATH),)
$(error CC_PATH is not set)
endif

build: ercc-container ecc-container

ercc-container:
make -C ${FPC_PATH}/ercc all docker

ecc-container:
if [ "${SGX_MODE}" = "HW" ]; then \
export HW_EXTENSION="-hw" ; \
fi && \
if [ "${WITH_GO}" = "YES" ]; then \
export ECC_PATH=${CC_PATH}/mrenclave ; \
else \
export ECC_PATH=${CC_PATH}/_build/lib ; \
fi && \
make -C ${CC_PATH} && \
make -C ${FPC_PATH}/ecc DOCKER_IMAGE=fpc/fpc-${CC_ID}$${HW_EXTENSION} DOCKER_ENCLAVE_SO_PATH=${ECC_PATH} all docker

.PHONY: ercc-ecc-start
ercc-ecc-start:
if [ ! -z "${DOCKERD_FPC_PATH}" ]; then \
export SGX_CREDENTIALS_PATH="${DOCKERD_FPC_PATH}/integration/config/ias"; \
Expand All @@ -40,10 +17,19 @@ ercc-ecc-start:
SGX_DEVICE_PATH=$$(if [ -e "/dev/isgx" ]; then echo "/dev/isgx"; elif [ -e "/dev/sgx/enclave" ]; then echo "/dev/sgx/enclave"; else echo "none"; fi) && \
[ "$${SGX_DEVICE_PATH}" != "none" ] || ( echo "ERROR: SGX_MODE is HW but no sgx device found"; exit 1; ) \
fi && \
env CC_ID=${CC_ID} FPC_VERSION=${FPC_VERSION} ${DOCKER_COMPOSE} up -d
env FPC_VERSION=${FPC_VERSION} ${DOCKER_COMPOSE} up -d

.PHONY: ercc-ecc-start
ercc-ecc-stop:
env CC_ID=${CC_ID} FPC_VERSION=${FPC_VERSION} ${DOCKER_COMPOSE} down
${DOCKER_COMPOSE} down

clobber:
docker compose down
./fabric-samples/test-network/network.sh down || true
rm -rf blockchain-explorer fabric-samples .env
docker system prune --force
docker network prune --force
docker volume prune --force

test:
./test.sh
55 changes: 30 additions & 25 deletions samples/deployment/test-network/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

This guide shows how to deploy and run a FPC Chaincode on test-network provided by [fabric-samples](https://github.com/hyperledger/fabric-samples).

Before moving forward, follow the main [README](../../../README.md) to set up your environment.
Before moving forward, follow the main [README](../../../README.md) to set up your environment and build the project.
This guide works also with the FPC Dev docker container.

## Prepare FPC Containers

[//]: # (TODO lets work this section)

FPC requires a special docker container to execute a FPC chaincode, similar to Fabric's `ccenv` container image but with additional support for Intel SGX.
You can pull the FPC chaincode environment image (`fabric-private-chaincode-ccenv`) from our Github repository or build them manually as follows:

Expand All @@ -20,27 +18,31 @@ make -C $FPC_PATH/utils/docker pull
make -C $FPC_PATH/utils/docker build
```

Next, we package the FPC components as docker images (building on top of `fabric-private-chaincode-ccenv`) which are deployed on our test network.
Use `CC_ID` and `CC_PATH` to define the FPC Chaincode you want to build.
Next, we package the FPC chaincode as a docker image which are deployed on the test-network using the chaincode as a service method.
The following snippet builds the `echo-go` FPC chaincode.
Note that we export `CC_ID`, `CC_NAME`, and `CC_VER` variables, which we will need

```bash
cd $FPC_PATH/samples/deployment/test-network
export CC_ID=echo
export CC_PATH=$FPC_PATH/samples/chaincode/echo
# TODO this needs to be changed!
export CC_VER=$(cat CC_PATH/)
make build
export CC_ID=echo-go
export CC_NAME=fpc-echo-go
make -C $FPC_PATH/samples/chaincode/echo-go build docker
export CC_VER=$(cat $FPC_PATH/samples/chaincode/echo-go/mrenclave)
```

Note: If you want to build with [mock-enclave](../../../ecc/chaincode/enclave/mock_enclave.go) rather than the real enclave-based one, build with
`make build GOTAGS="-tags mock_ecc"` instead.
Please verify that the `fpc/fpc-echo-go` image exists using `docker images | grep fpc-echo-go`.

Finally, make sure you have the FPC Enclave Registry container image already build (see the main [README](../../../README.md)), otherwise you can build it as follows:

```bash
make -C ${FPC_PATH}/ercc all docker
```


## Prepare the Test Network

Next, we set up the Fabric samples [test-network](https://github.com/hyperledger/fabric-samples/tree/main/test-network).

Since the Fabric samples test network uses docker (and docker-compose) to run the Fabric components, we need to make sure that it works within our FPC dev container environment.
Since the Fabric samples test network uses docker (and docker compose) to run the Fabric components, we need to make sure that it works within our FPC dev container environment.
In particular, as we use the host docker daemon, there may be issues with docker mounts.

For convenience, we provide a `setup.sh` script that clones the fabric samples repository, downloads all required fabric container images and binaries, and replaces all relative mount paths in the compose files with absolute path on the host system.
Expand All @@ -57,7 +59,7 @@ Let's start the Fabric-Samples test network.

```bash
cd $FPC_PATH/samples/deployment/test-network/fabric-samples/test-network
./network.sh up createChannel -ca -c mychannel
./network.sh up createChannel -c mychannel
```


Expand All @@ -80,7 +82,7 @@ Make sure you have set `CC_ID` to the same chaincode ID as used in the earlier s

```bash
# Start FPC container
make ercc-ecc-start
make -C $FPC_PATH/samples/deployment/test-network ercc-ecc-start
```

You should see two instances of the FPC Echo chaincode and two instances of the FPC Enclave Registry chaincode running such as in the following example:
Expand All @@ -100,7 +102,7 @@ ercc.peer0.org1.example.com | 2021-05-11 16:11:32.199 UTC [ercc] main -> INFO
```

The FPC Chaincode is now up and running, ready for processing invocations!
Note that the containers are running in foreground in your terminal using docker-compose.
Note that the containers are running in the background in your terminal using docker-compose.


## Interact with the FPC Chaincode
Expand Down Expand Up @@ -130,7 +132,7 @@ In order to initiate the FPC Chaincode enclave and register it with the FPC Encl
export SGX_CREDENTIALS_PATH=$FPC_PATH/config/ias

cd $FPC_PATH/samples/application/simple-go
CC_ID=echo ORG_NAME=Org1 go run . -withLifecycleInitEnclave
CC_ID=echo-go ORG_NAME=Org1 go run . -withLifecycleInitEnclave
```

Note that we execute the go app as `Org1`, thereby creating and registering the FPC Chaincode enclave at `peer0.org1.example.com`. Alternatively, we could run this as `Org2` to initiate the enclave at `peer0.org2.example.com`.
Expand All @@ -139,8 +141,8 @@ Afterwards you _must_ run the application without the `withLifecycleInitEnclave`

```bash
cd $FPC_PATH/samples/application/simple-go
CC_ID=echo ORG_NAME=Org1 go run .
CC_ID=echo ORG_NAME=Org2 go run .
CC_ID=echo-go ORG_NAME=Org1 go run .
CC_ID=echo-go ORG_NAME=Org2 go run .
```

### How to use simple-cli-go
Expand All @@ -153,7 +155,7 @@ cd $FPC_PATH/samples/application/simple-cli-go
make

# export fpcclient settings
export CC_NAME=echo
export CC_NAME=echo-go
export CHANNEL_NAME=mychannel
export CORE_PEER_ADDRESS=localhost:7051
export CORE_PEER_ID=peer0.org1.example.com
Expand Down Expand Up @@ -182,22 +184,25 @@ export SGX_CREDENTIALS_PATH=$FPC_PATH/config/ias
Since we opened a new terminal to interact with the FPC Chaincode, to be able to shutdown the FPC chaincode you need to define the environment variables that set the chaincode name and path.

```bash
export CC_ID=echo
export CC_PATH=$FPC_PATH/samples/chaincode/echo
make -C $FPC_PATH/samples/deployment/test-network ercc-ecc-stop
cd $FPC_PATH/samples/deployment/test-network/fabric-samples/test-network
./network.sh down
```

## Using HelloWorld chaincode on the test-network

In this section we show how you can run a different FPC chaincode on the test network. For example, you can use the [HelloWorld](../../chaincode/helloworld/README.md) code instead of the echo code. To do so you have to change the values of the environment variables set at the beginning `CC_ID` and `CC_PATH`.
In this section we show how you can run a different FPC chaincode on the test network. For example, you can use the [HelloWorld](../../chaincode/helloworld/README.md) code instead of the echo-go code.
To do so you have to build the chaincode as follows:

```bash
export CC_ID=helloworld
export CC_PATH=$FPC_PATH/samples/chaincode/helloworld
export CC_NAME=fpc-helloworld
make -C $FPC_PATH/samples/chaincode/helloworld build docker
export CC_VER=$(cat $FPC_PATH/samples/chaincode/helloworld/_build/lib/mrenclave)
```

Repeat the process of starting the test-network and deployment as described above.

Afterwards to test you would use [simple-cli-go](#How-to-use-simple-cli-go). You would need to verify that the `CC_NAME` variable is set to helloworld and then to interact you would execute the chaincode as follows:

```bash
Expand Down
2 changes: 2 additions & 0 deletions samples/deployment/test-network/installFPC.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ ORG1_ECC_PKG_ID=$(${NETWORK_CMD} cc list -org 1 | grep "Label: ${CC_ID}_${CC_VER
ORG2_ECC_PKG_ID=$(${NETWORK_CMD} cc list -org 2 | grep "Label: ${CC_ID}_${CC_VER}" | awk '{print $3}' | sed 's/.$//')

cat > .env << EOF
CC_ID="$CC_ID"
CC_VER="${CC_VER}"
ORG1_ECC_PKG_ID="${ORG1_ECC_PKG_ID}"
ORG1_ERCC_PKG_ID="${ORG1_ERCC_PKG_ID}"
ORG2_ECC_PKG_ID="${ORG2_ECC_PKG_ID}"
Expand Down
13 changes: 6 additions & 7 deletions samples/deployment/test-network/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,18 @@ else
fi
echo "set FPC_PATH_HOST = ${FPC_PATH_HOST}"

FABRIC_SAMPLES_HOST=${FPC_PATH}/samples/deployment/test-network/fabric-samples
DOCKERD_FABRIC_SAMPLES_HOST=${FPC_PATH_HOST}samples/deployment/test-network/fabric-samples
FABRIC_SAMPLES_HOST=${FPC_PATH_HOST}/samples/deployment/test-network/fabric-samples
TEST_NETWORK_HOST=${FABRIC_SAMPLES_HOST}/test-network
DOCKERD_TEST_NETWORK_HOST=${DOCKERD_FABRIC_SAMPLES_HOST}/test-network
TEST_NETWORK=${FABRIC_SAMPLES}/test-network

echo "set DOCKERD_TEST_NETWORK_HOST = ${DOCKERD_TEST_NETWORK_HOST}"
echo "set FABRIC_SAMPLES_HOST = ${FABRIC_SAMPLES_HOST}"
echo "set TEST_NETWORK_HOST = ${TEST_NETWORK_HOST}"
echo "Resolving relative docker volume paths"

# replace "../" with absolute path
find "${TEST_NETWORK_HOST}/compose" -maxdepth 1 \( -name '*compose*.yaml' -o -name '*compose*.yml' \) -exec sed -i -E 's+(- )(\.\.)(/)+\1'"${DOCKERD_TEST_NETWORK_HOST}"'\3+g' {} \;
find "${TEST_NETWORK}/compose" -maxdepth 1 \( -name '*compose*.yaml' -o -name '*compose*.yml' \) -exec sed -i -E 's+(- )(\.\.)(/)+\1'"${TEST_NETWORK_HOST}"'\3+g' {} \;
# replace "./" with absolute path
find "${TEST_NETWORK_HOST}/compose" -mindepth 2 -maxdepth 2 \( -name '*compose*.yaml' -o -name '*compose*.yml' \) -exec sed -i -E 's+(- )(\.)(/)+\1'"${DOCKERD_TEST_NETWORK_HOST}/compose"'\3+g' {} \;
find "${TEST_NETWORK}/compose" -mindepth 2 -maxdepth 2 \( -name '*compose*.yaml' -o -name '*compose*.yml' \) -exec sed -i -E 's+(- )(\.)(/)+\1'"${TEST_NETWORK_HOST}/compose"'\3+g' {} \;


##############################################################################################
Expand Down Expand Up @@ -104,7 +103,7 @@ wget -O "${BE_DOCKER_COMPOSE}" https://raw.githubusercontent.com/hyperledger/blo
cat > "${BE_PATH}/.env" << EOF
EXPLORER_CONFIG_FILE_PATH=${BE_PATH_HOST}/config.json
EXPLORER_PROFILE_DIR_PATH=${BE_PATH_HOST}/connection-profile
FABRIC_CRYPTO_PATH=${DOCKERD_TEST_NETWORK_HOST}/organizations
FABRIC_CRYPTO_PATH=${TEST_NETWORK_HOST}/organizations
EOF


Expand Down
Loading

0 comments on commit 2a3ee9c

Please sign in to comment.