Skip to content

Commit fdf4625

Browse files
committed
complete work done in 596
Signed-off-by: OsamaRab3 <osrab3@gmail.com>
1 parent 617cc46 commit fdf4625

17 files changed

+345
-128
lines changed

e2e/__snapshots__/extendConfig.test.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2865,7 +2865,7 @@ exports[`extend config samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.
28652865
"requiredPeerCount": 1,
28662866
},
28672867
],
2868-
"privateDataConfigFile": "collections/or-policy-chaincode.json",
2868+
"privateDataConfigFile": "collections/my-channel1-or-policy-chaincode.json",
28692869
"version": "0.0.1",
28702870
},
28712871
{
@@ -3275,7 +3275,7 @@ exports[`extend config samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.
32753275
"requiredPeerCount": 1,
32763276
},
32773277
],
3278-
"privateDataConfigFile": "collections/and-policy-chaincode.json",
3278+
"privateDataConfigFile": "collections/my-channel1-and-policy-chaincode.json",
32793279
"version": "0.0.1",
32803280
},
32813281
],
@@ -9491,7 +9491,7 @@ exports[`extend config samples/fablo-config-hlf3-1org-1chaincode-raft-ccaas.json
94919491
"name": "chaincode1",
94929492
"peerChaincodeInstances": [
94939493
{
9494-
"containerName": "ccaas-peer0.org1.example.com-chaincode1",
9494+
"containerName": "ccaas-peer0.org1.example.com-my-channel1-chaincode1",
94959495
"orgDomain": "org1.example.com",
94969496
"peerAddress": "peer0.org1.example.com",
94979497
"port": 17041,
@@ -12216,7 +12216,7 @@ exports[`extend config samples/invalid-fablo-config.json 1`] = `
1221612216
"name": "chaincode1",
1221712217
"peerChaincodeInstances": [
1221812218
{
12219-
"containerName": "ccaas-peer0.org1.example.com-chaincode1",
12219+
"containerName": "ccaas-peer0.org1.example.com-my-channel1-chaincode1",
1222012220
"orgDomain": "org1.example.com",
1222112221
"peerAddress": "peer0.org1.example.com",
1222212222
"port": 17041,

e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode-k8s.json.test.ts.snap

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,12 @@ buildAndInstallChaincode() {
337337
local CHAINCODE_LANG="$3"
338338
local CHAINCODE_DIR_PATH="$4"
339339
local CHAINCODE_VERSION="$5"
340-
local CHAINCODE_LABEL="\${CHAINCODE_NAME}_$CHAINCODE_VERSION"
341340
local USER="$6"
342341
local CONFIG="$7"
342+
local CHANNEL_NAME="$8"
343+
344+
# Include channel name in the chaincode label to ensure uniqueness
345+
local CHAINCODE_LABEL="\${CHANNEL_NAME}-\${CHAINCODE_NAME}_$CHAINCODE_VERSION"
343346
344347
if [ -z "$CHAINCODE_NAME" ]; then
345348
echo "Error: chaincode name is not provided"
@@ -375,6 +378,9 @@ approveChaincode() {
375378
local MSP="$7"
376379
local SEQUENCE
377380
381+
# Include channel name in the chaincode label to ensure uniqueness
382+
local CHAINCODE_LABEL="\${CHANNEL_NAME}-\${CHAINCODE_NAME}_$CHAINCODE_VERSION"
383+
378384
SEQUENCE="$(kubectl hlf chaincode querycommitted --channel="$CHANNEL_NAME" --config="$CONFIG" --user="$USER" --peer="$PEER" 2>/dev/null | awk '{print $3}' | sed -n '2p')"
379385
SEQUENCE=$((SEQUENCE + 1))
380386
@@ -408,16 +414,18 @@ approveChaincode() {
408414
}
409415
410416
commitChaincode() {
411-
412417
local CHAINCODE_NAME="$1"
413-
local PEER=$2
418+
local PEER="$2"
414419
local CHAINCODE_VERSION="$3"
415420
local CHANNEL_NAME="$4"
416421
local USER="$5"
417422
local CONFIG="$6"
418423
local MSP="$7"
419424
local SEQUENCE
420425
426+
# Include channel name in the chaincode label to ensure uniqueness
427+
local CHAINCODE_LABEL="\${CHANNEL_NAME}-\${CHAINCODE_NAME}_$CHAINCODE_VERSION"
428+
421429
SEQUENCE="$(kubectl hlf chaincode querycommitted --channel="$CHANNEL_NAME" --config="$CONFIG" --user="$USER" --peer="$PEER" 2>/dev/null | awk '{print $3}' | sed -n '2p')"
422430
SEQUENCE=$((SEQUENCE + 1))
423431

e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode-peer-dev-mode.json.test.ts.snap

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2522,8 +2522,10 @@ chaincodePackageCCaaS() {
25222522
inputLog "CONTAINER_PORT: $CONTAINER_PORT"
25232523
inputLog "TLS_ENABLED: $TLS_ENABLED"
25242524
2525-
# Use the same container name logic as startCCaaSContainer
2526-
local ACTUAL_CONTAINER_NAME="ccaas-\${PEER_ADDRESS%%:*}-\${CHAINCODE_NAME}"
2525+
# Include channel name in the container name to ensure uniqueness
2526+
local CHANNEL_NAME=$9 # Get the channel name as the 9th parameter
2527+
local ACTUAL_CONTAINER_NAME="ccaas-\${PEER_ADDRESS%%:*}-\${CHANNEL_NAME}-\${CHAINCODE_NAME}"
2528+
ACTUAL_CONTAINER_NAME=$(echo "$ACTUAL_CONTAINER_NAME" | tr '[:upper:]' '[:lower:]')
25272529
local PACKAGE_DIR="./chaincode-packages/ccaas_$ACTUAL_CONTAINER_NAME"
25282530
25292531
mkdir -p "$PACKAGE_DIR"
@@ -2572,8 +2574,10 @@ chaincodeInstall() {
25722574
local PEER_ADDRESS=$2
25732575
local CHAINCODE_NAME=$3
25742576
local CHAINCODE_VERSION=$4
2575-
local CHAINCODE_LABEL="\${CHAINCODE_NAME}_$CHAINCODE_VERSION"
2576-
local CA_CERT=$5
2577+
local CHANNEL_NAME=$5
2578+
local CA_CERT=$6
2579+
# Include channel name in the chaincode label to ensure uniqueness
2580+
local CHAINCODE_LABEL="\${CHANNEL_NAME}-\${CHAINCODE_NAME}_$CHAINCODE_VERSION"
25772581
25782582
echo "Installing chaincode $CHAINCODE_NAME..."
25792583
inputLog "CHAINCODE_VERSION: $CHAINCODE_VERSION"
@@ -2598,8 +2602,11 @@ startCCaaSContainer() {
25982602
local EXTERNAL_PORT="$5"
25992603
local CLI_NAME="$6"
26002604
local CA_CERT="$7"
2605+
local CHANNEL_NAME="$8" # Get the channel name as the 8th parameter
26012606
2602-
local CONTAINER_NAME="ccaas-\${PEER_ADDRESS%%:*}-\${CHAINCODE_NAME}"
2607+
# Include channel name in the container name to ensure uniqueness
2608+
local CONTAINER_NAME="ccaas-\${PEER_ADDRESS%%:*}-\${CHANNEL_NAME}-\${CHAINCODE_NAME}"
2609+
CONTAINER_NAME=$(echo "$CONTAINER_NAME" | tr '[:upper:]' '[:lower:]')
26032610
26042611
# Query installed chaincodes to get the package ID
26052612
local CA_CERT_PARAMS=()
@@ -2672,7 +2679,8 @@ chaincodeApprove() {
26722679
local CHANNEL_NAME="$3"
26732680
local CHAINCODE_NAME=$4
26742681
local CHAINCODE_VERSION=$5
2675-
local CHAINCODE_LABEL="\${CHAINCODE_NAME}_$CHAINCODE_VERSION"
2682+
# Include channel name in the chaincode label to ensure uniqueness
2683+
local CHAINCODE_LABEL="\${CHANNEL_NAME}-\${CHAINCODE_NAME}_$CHAINCODE_VERSION"
26762684
local ORDERER_URL=$6
26772685
local ENDORSEMENT=$7
26782686
local INIT_REQUIRED=$8
@@ -2758,6 +2766,8 @@ chaincodeCommit() {
27582766
local CHANNEL_NAME="$3"
27592767
local CHAINCODE_NAME=$4
27602768
local CHAINCODE_VERSION=$5
2769+
# Include channel name in the chaincode label to ensure uniqueness
2770+
local CHAINCODE_LABEL="\${CHANNEL_NAME}-\${CHAINCODE_NAME}_$CHAINCODE_VERSION"
27612771
local ORDERER_URL=$6
27622772
local ENDORSEMENT=$7
27632773
local INIT_REQUIRED=$8

e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode-raft-ccaas.json.test.ts.snap

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,7 +1734,7 @@ installChaincodes() {
17341734
if [ -n "$(ls "$CHAINCODES_BASE_DIR/")" ]; then
17351735
local version="0.0.1"
17361736
printHeadline "Packaging chaincode 'chaincode1'" "U1F60E"
1737-
chaincodePackageCCaaS "cli.org1.example.com" "peer0.org1.example.com" "chaincode1" "$version" "ghcr.io/fablo-io/fablo-sample-kv-node-chaincode:2.2.0" "17041" "ccaas-peer0.org1.example.com-chaincode1" "true"
1737+
chaincodePackageCCaaS "cli.org1.example.com" "peer0.org1.example.com" "chaincode1" "$version" "ghcr.io/fablo-io/fablo-sample-kv-node-chaincode:2.2.0" "17041" "ccaas-peer0.org1.example.com-my-channel1-chaincode1" "true"
17381738
printHeadline "Installing 'chaincode1' for Org1" "U1F60E"
17391739
chaincodeInstall "cli.org1.example.com" "peer0.org1.example.com:7041" "chaincode1" "$version" "crypto-orderer/tlsca.orderer.example.com-cert.pem"
17401740
startCCaaSContainer "peer0.org1.example.com:7041" "chaincode1" "chaincode1_$version" "ghcr.io/fablo-io/fablo-sample-kv-node-chaincode:2.2.0" "17041" "cli.org1.example.com" "crypto-orderer/tlsca.orderer.example.com-cert.pem"
@@ -1764,7 +1764,7 @@ installChaincode() {
17641764
if [ "$chaincodeName" = "chaincode1" ]; then
17651765
if [ -n "$(ls "$CHAINCODES_BASE_DIR/")" ]; then
17661766
printHeadline "Packaging chaincode 'chaincode1'" "U1F60E"
1767-
chaincodePackageCCaaS "cli.org1.example.com" "peer0.org1.example.com" "chaincode1" "$version" "ghcr.io/fablo-io/fablo-sample-kv-node-chaincode:2.2.0" "17041" "ccaas-peer0.org1.example.com-chaincode1" "true"
1767+
chaincodePackageCCaaS "cli.org1.example.com" "peer0.org1.example.com" "chaincode1" "$version" "ghcr.io/fablo-io/fablo-sample-kv-node-chaincode:2.2.0" "17041" "ccaas-peer0.org1.example.com-my-channel1-chaincode1" "true"
17681768
printHeadline "Installing 'chaincode1' for Org1" "U1F60E"
17691769
chaincodeInstall "cli.org1.example.com" "peer0.org1.example.com:7041" "chaincode1" "$version" "crypto-orderer/tlsca.orderer.example.com-cert.pem"
17701770
startCCaaSContainer "peer0.org1.example.com:7041" "chaincode1" "chaincode1_$version" "ghcr.io/fablo-io/fablo-sample-kv-node-chaincode:2.2.0" "17041" "cli.org1.example.com" "crypto-orderer/tlsca.orderer.example.com-cert.pem"
@@ -1800,7 +1800,7 @@ upgradeChaincode() {
18001800
if [ "$chaincodeName" = "chaincode1" ]; then
18011801
if [ -n "$(ls "$CHAINCODES_BASE_DIR/")" ]; then
18021802
printHeadline "Packaging chaincode 'chaincode1'" "U1F60E"
1803-
chaincodePackageCCaaS "cli.org1.example.com" "peer0.org1.example.com" "chaincode1" "$version" "ghcr.io/fablo-io/fablo-sample-kv-node-chaincode:2.2.0" "17041" "ccaas-peer0.org1.example.com-chaincode1" "true"
1803+
chaincodePackageCCaaS "cli.org1.example.com" "peer0.org1.example.com" "chaincode1" "$version" "ghcr.io/fablo-io/fablo-sample-kv-node-chaincode:2.2.0" "17041" "ccaas-peer0.org1.example.com-my-channel1-chaincode1" "true"
18041804
printHeadline "Installing 'chaincode1' for Org1" "U1F60E"
18051805
chaincodeInstall "cli.org1.example.com" "peer0.org1.example.com:7041" "chaincode1" "$version" "crypto-orderer/tlsca.orderer.example.com-cert.pem"
18061806
startCCaaSContainer "peer0.org1.example.com:7041" "chaincode1" "chaincode1_$version" "ghcr.io/fablo-io/fablo-sample-kv-node-chaincode:2.2.0" "17041" "cli.org1.example.com" "crypto-orderer/tlsca.orderer.example.com-cert.pem"
@@ -2623,8 +2623,10 @@ chaincodePackageCCaaS() {
26232623
inputLog "CONTAINER_PORT: $CONTAINER_PORT"
26242624
inputLog "TLS_ENABLED: $TLS_ENABLED"
26252625
2626-
# Use the same container name logic as startCCaaSContainer
2627-
local ACTUAL_CONTAINER_NAME="ccaas-\${PEER_ADDRESS%%:*}-\${CHAINCODE_NAME}"
2626+
# Include channel name in the container name to ensure uniqueness
2627+
local CHANNEL_NAME=$9 # Get the channel name as the 9th parameter
2628+
local ACTUAL_CONTAINER_NAME="ccaas-\${PEER_ADDRESS%%:*}-\${CHANNEL_NAME}-\${CHAINCODE_NAME}"
2629+
ACTUAL_CONTAINER_NAME=$(echo "$ACTUAL_CONTAINER_NAME" | tr '[:upper:]' '[:lower:]')
26282630
local PACKAGE_DIR="./chaincode-packages/ccaas_$ACTUAL_CONTAINER_NAME"
26292631
26302632
mkdir -p "$PACKAGE_DIR"
@@ -2673,8 +2675,10 @@ chaincodeInstall() {
26732675
local PEER_ADDRESS=$2
26742676
local CHAINCODE_NAME=$3
26752677
local CHAINCODE_VERSION=$4
2676-
local CHAINCODE_LABEL="\${CHAINCODE_NAME}_$CHAINCODE_VERSION"
2677-
local CA_CERT=$5
2678+
local CHANNEL_NAME=$5
2679+
local CA_CERT=$6
2680+
# Include channel name in the chaincode label to ensure uniqueness
2681+
local CHAINCODE_LABEL="\${CHANNEL_NAME}-\${CHAINCODE_NAME}_$CHAINCODE_VERSION"
26782682
26792683
echo "Installing chaincode $CHAINCODE_NAME..."
26802684
inputLog "CHAINCODE_VERSION: $CHAINCODE_VERSION"
@@ -2699,8 +2703,11 @@ startCCaaSContainer() {
26992703
local EXTERNAL_PORT="$5"
27002704
local CLI_NAME="$6"
27012705
local CA_CERT="$7"
2706+
local CHANNEL_NAME="$8" # Get the channel name as the 8th parameter
27022707
2703-
local CONTAINER_NAME="ccaas-\${PEER_ADDRESS%%:*}-\${CHAINCODE_NAME}"
2708+
# Include channel name in the container name to ensure uniqueness
2709+
local CONTAINER_NAME="ccaas-\${PEER_ADDRESS%%:*}-\${CHANNEL_NAME}-\${CHAINCODE_NAME}"
2710+
CONTAINER_NAME=$(echo "$CONTAINER_NAME" | tr '[:upper:]' '[:lower:]')
27042711
27052712
# Query installed chaincodes to get the package ID
27062713
local CA_CERT_PARAMS=()
@@ -2773,7 +2780,8 @@ chaincodeApprove() {
27732780
local CHANNEL_NAME="$3"
27742781
local CHAINCODE_NAME=$4
27752782
local CHAINCODE_VERSION=$5
2776-
local CHAINCODE_LABEL="\${CHAINCODE_NAME}_$CHAINCODE_VERSION"
2783+
# Include channel name in the chaincode label to ensure uniqueness
2784+
local CHAINCODE_LABEL="\${CHANNEL_NAME}-\${CHAINCODE_NAME}_$CHAINCODE_VERSION"
27772785
local ORDERER_URL=$6
27782786
local ENDORSEMENT=$7
27792787
local INIT_REQUIRED=$8
@@ -2859,6 +2867,8 @@ chaincodeCommit() {
28592867
local CHANNEL_NAME="$3"
28602868
local CHAINCODE_NAME=$4
28612869
local CHAINCODE_VERSION=$5
2870+
# Include channel name in the chaincode label to ensure uniqueness
2871+
local CHAINCODE_LABEL="\${CHANNEL_NAME}-\${CHAINCODE_NAME}_$CHAINCODE_VERSION"
28622872
local ORDERER_URL=$6
28632873
local ENDORSEMENT=$7
28642874
local INIT_REQUIRED=$8

e2e/__snapshots__/fablo-config-hlf2-1org-1chaincode.json.test.ts.snap

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2590,8 +2590,10 @@ chaincodePackageCCaaS() {
25902590
inputLog "CONTAINER_PORT: $CONTAINER_PORT"
25912591
inputLog "TLS_ENABLED: $TLS_ENABLED"
25922592
2593-
# Use the same container name logic as startCCaaSContainer
2594-
local ACTUAL_CONTAINER_NAME="ccaas-\${PEER_ADDRESS%%:*}-\${CHAINCODE_NAME}"
2593+
# Include channel name in the container name to ensure uniqueness
2594+
local CHANNEL_NAME=$9 # Get the channel name as the 9th parameter
2595+
local ACTUAL_CONTAINER_NAME="ccaas-\${PEER_ADDRESS%%:*}-\${CHANNEL_NAME}-\${CHAINCODE_NAME}"
2596+
ACTUAL_CONTAINER_NAME=$(echo "$ACTUAL_CONTAINER_NAME" | tr '[:upper:]' '[:lower:]')
25952597
local PACKAGE_DIR="./chaincode-packages/ccaas_$ACTUAL_CONTAINER_NAME"
25962598
25972599
mkdir -p "$PACKAGE_DIR"
@@ -2640,8 +2642,10 @@ chaincodeInstall() {
26402642
local PEER_ADDRESS=$2
26412643
local CHAINCODE_NAME=$3
26422644
local CHAINCODE_VERSION=$4
2643-
local CHAINCODE_LABEL="\${CHAINCODE_NAME}_$CHAINCODE_VERSION"
2644-
local CA_CERT=$5
2645+
local CHANNEL_NAME=$5
2646+
local CA_CERT=$6
2647+
# Include channel name in the chaincode label to ensure uniqueness
2648+
local CHAINCODE_LABEL="\${CHANNEL_NAME}-\${CHAINCODE_NAME}_$CHAINCODE_VERSION"
26452649
26462650
echo "Installing chaincode $CHAINCODE_NAME..."
26472651
inputLog "CHAINCODE_VERSION: $CHAINCODE_VERSION"
@@ -2666,8 +2670,11 @@ startCCaaSContainer() {
26662670
local EXTERNAL_PORT="$5"
26672671
local CLI_NAME="$6"
26682672
local CA_CERT="$7"
2673+
local CHANNEL_NAME="$8" # Get the channel name as the 8th parameter
26692674
2670-
local CONTAINER_NAME="ccaas-\${PEER_ADDRESS%%:*}-\${CHAINCODE_NAME}"
2675+
# Include channel name in the container name to ensure uniqueness
2676+
local CONTAINER_NAME="ccaas-\${PEER_ADDRESS%%:*}-\${CHANNEL_NAME}-\${CHAINCODE_NAME}"
2677+
CONTAINER_NAME=$(echo "$CONTAINER_NAME" | tr '[:upper:]' '[:lower:]')
26712678
26722679
# Query installed chaincodes to get the package ID
26732680
local CA_CERT_PARAMS=()
@@ -2740,7 +2747,8 @@ chaincodeApprove() {
27402747
local CHANNEL_NAME="$3"
27412748
local CHAINCODE_NAME=$4
27422749
local CHAINCODE_VERSION=$5
2743-
local CHAINCODE_LABEL="\${CHAINCODE_NAME}_$CHAINCODE_VERSION"
2750+
# Include channel name in the chaincode label to ensure uniqueness
2751+
local CHAINCODE_LABEL="\${CHANNEL_NAME}-\${CHAINCODE_NAME}_$CHAINCODE_VERSION"
27442752
local ORDERER_URL=$6
27452753
local ENDORSEMENT=$7
27462754
local INIT_REQUIRED=$8
@@ -2826,6 +2834,8 @@ chaincodeCommit() {
28262834
local CHANNEL_NAME="$3"
28272835
local CHAINCODE_NAME=$4
28282836
local CHAINCODE_VERSION=$5
2837+
# Include channel name in the chaincode label to ensure uniqueness
2838+
local CHAINCODE_LABEL="\${CHANNEL_NAME}-\${CHAINCODE_NAME}_$CHAINCODE_VERSION"
28292839
local ORDERER_URL=$6
28302840
local ENDORSEMENT=$7
28312841
local INIT_REQUIRED=$8

0 commit comments

Comments
 (0)