Skip to content

Commit 99171d8

Browse files
authored
Merge branch 'main' into fix-228
2 parents d89283d + bc89fd3 commit 99171d8

File tree

13 files changed

+1546
-7
lines changed

13 files changed

+1546
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## 2.3.0
2-
3-
### Features
1+
## 2.3.0
2+
* Support for running Java chaincode in development mode
3+
[#553](https://github.com/hyperledger-labs/fablo/pull/553)
44
* Hardcode fablo config inside init generator
55
[#554](https://github.com/hyperledger-labs/fablo/pull/554)
66
* Publish sample chaincode Docker image
@@ -10,7 +10,6 @@
1010
* Export network topology with Mermaid
1111
[#565](https://github.com/hyperledger-labs/fablo/pull/565)
1212

13-
1413
## 2.2.0
1514

1615
### Features

README.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ This feature allows hot reload of chaincode code and speeds up the development a
264264
Fablo will run peers in dev mode when `global.peerDevMode` is set to `true`.
265265
Note: in this case TLS has to be disabled, otherwise config validation fails.
266266
267+
#### For Node.js Chaincode:
268+
267269
The simplest way of trying Fablo with dev mode is as follows:
268270
269271
1. Execute `fablo init node dev`.
@@ -278,7 +280,7 @@ The simplest way of trying Fablo with dev mode is as follows:
278280
```
279281
Now, when you update the chaincode source code, it will be automatically refreshed on Hyperledger Fabric Network.
280282
281-
Our sample chaincode definition contains some scripts for running chaincode in dev mode:
283+
The relevant scripts in `package.json` look like:
282284
283285
```json
284286
"scripts": {
@@ -288,13 +290,44 @@ Our sample chaincode definition contains some scripts for running chaincode in d
288290
...
289291
},
290292
```
291-
292-
Worth considering:
293+
**Worth considering for Node.js chaincode:**
293294
* If you want chaincode to be running on multiple peers, you need to start it multiple times, specifying different `--peer.address`
294295
* In case of errors ensure you have the same `--chaincode-id-name` as `CC_PACKAGE_ID` in Fablo output.
295296
296297
Feel free to update this scripts to adjust it to your chaincode definition.
297298
299+
300+
#### For Java Chaincode:
301+
302+
To run Java chaincode in dev mode:
303+
304+
1. Make sure your Fablo config has `global.peerDevMode` set to `true` and TLS disabled.
305+
306+
2. Start the network with `fablo up`.
307+
308+
3. Build and run the Java chaincode locally. As a sample you may use the chaincode from the Fablo source code from the `samples/chaincodes/java-chaincode` directory. Ensure a proper relative path is provided in Fablo config.
309+
```bash
310+
cd samples/chaincodes/java-chaincode
311+
./run-dev.sh
312+
```
313+
314+
The `run-dev.sh` script will:
315+
- Build the chaincode using Gradle's shadowJar task
316+
- Automatically detect the peer's IP address from the Docker container
317+
- Start the chaincode with debug logging enabled
318+
- Connect to the peer at port 7051
319+
320+
For local development and review:
321+
- The chaincode will run with the name `simple-asset:1.0`
322+
- Debug level logging is enabled via `CORE_CHAINCODE_LOGLEVEL=debug`
323+
- You can modify the Java code and rebuild/restart to see changes
324+
- The peer connection is automatically configured using the Docker container's IP
325+
326+
**Worth considering for Java chaincode:**
327+
- If you want the chaincode running on multiple peers, start multiple instances with different `CORE_PEER_ADDRESS` values
328+
- Ensure `CORE_CHAINCODE_ID_NAME` matches the chaincode name and version in your Fablo config (for instance `chaincode1:0.0.1`)
329+
- The Java chaincode uses Gradle's ShadowJar plugin to package all dependencies into a single JAR file
330+
298331
## Channel scripts
299332
300333
### channel help

e2e-network/docker/test-05-v3.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,41 @@ waitForContainer "peer0.org1.example.com" "Membership view has changed. peers we
6161
waitForContainer "peer1.org1.example.com" "Learning about the configured anchor peers of Org1MSP for channel my-channel1"
6262
waitForContainer "peer1.org1.example.com" "Membership view has changed. peers went online:.*peer0.org1.example.com:7041"
6363

64+
# Gateway client test
65+
GATEWAY_CLIENT_DIR="$FABLO_HOME/samples/gateway/node"
66+
GATEWAY_CLIENT_OUTPUT_FILE="$TEST_LOGS/gateway_client.log"
67+
echo "Testing Node.js Gateway client..."
68+
69+
echo "Installing gateway client dependencies..."
70+
(cd "$GATEWAY_CLIENT_DIR" && npm install --silent --no-progress)
71+
72+
echo "Running Node.js Gateway client and checking output..."
73+
(
74+
cd "$GATEWAY_CLIENT_DIR" &&
75+
export \
76+
CHANNEL_NAME="my-channel1" \
77+
CONTRACT_NAME="chaincode1" \
78+
MSP_ID="Org1MSP" \
79+
PEER_ORG_NAME="peer0.org1.example.com" \
80+
PEER_GATEWAY_URL="localhost:7041" \
81+
TLS_ROOT_CERT="$TEST_TMP/fablo-target/fabric-config/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" \
82+
CREDENTIALS="$TEST_TMP/fablo-target/fabric-config/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/signcerts/User1@org1.example.com-cert.pem" \
83+
PRIVATE_KEY_PEM="$TEST_TMP/fablo-target/fabric-config/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/keystore/priv-key.pem" &&
84+
node server.js > "$GATEWAY_CLIENT_OUTPUT_FILE" 2>&1
85+
)
86+
GATEWAY_EXIT_CODE=$?
87+
88+
if [ $GATEWAY_EXIT_CODE -ne 0 ]; then
89+
echo "❌ failed: Node.js Gateway client script failed with exit code $GATEWAY_EXIT_CODE."
90+
cat "$GATEWAY_CLIENT_OUTPUT_FILE"
91+
exit 1
92+
fi
93+
94+
expectCommand "cat \"$GATEWAY_CLIENT_OUTPUT_FILE\"" "\"success\":\"OK\""
95+
96+
echo "🎉 Node.js Gateway client test complete 🎉"
97+
98+
6499
# Test simple chaincode
65100
expectInvoke "peer0.org1.example.com" "my-channel1" "chaincode1" \
66101
'{"Args":["KVContract:put", "name", "Willy Wonka"]}' \

0 commit comments

Comments
 (0)