Skip to content

Commit

Permalink
Merge pull request #411 from jnjerin/fablo-chaincode-list-withTLS
Browse files Browse the repository at this point in the history
Created support for chaincodes list command (with TLS)
  • Loading branch information
dzikowski authored Sep 12, 2023
2 parents 45d2fa6 + 9e69f48 commit 128b524
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 61 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

### Features
* Initial support for Kubernetes
* Basic support for chaincode invoke command
* Support for `chaincodes list command`
* Basic support for `chaincode invoke` command
* Support for `chaincodes list` command (tls and non-tls)

### Fixes
* Remove unsupported test library and dependencies
* Updated Node.js version from 12 to 16 in chaincode
Expand Down
20 changes: 11 additions & 9 deletions e2e-network/docker/test-02-raft-2orgs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ TEST_TMP="$(rm -rf "$0.tmpdir" && mkdir -p "$0.tmpdir" && (cd "$0.tmpdir" && pwd
TEST_LOGS="$(mkdir -p "$0.logs" && (cd "$0.logs" && pwd))"
FABLO_HOME="$TEST_TMP/../../.."

export FABLO_HOME

CONFIG="$FABLO_HOME/samples/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml"

networkUp() {
Expand Down Expand Up @@ -33,7 +35,7 @@ waitForContainer() {
}

waitForChaincode() {
sh "$TEST_TMP/../wait-for-chaincode-tls.sh" "$1" "$2" "$3" "$4" "$5"
(cd "$TEST_TMP" && sh ../wait-for-chaincode.sh "$1" "$2" "$3" "$4")
}

expectInvokeRest() {
Expand Down Expand Up @@ -82,10 +84,10 @@ waitForContainer "peer1.org2.example.com" "Anchor peer for channel my-channel2 w
waitForContainer "peer1.org2.example.com" "Membership view has changed. peers went online:.*peer1.org1.example.com:7062"

# check if chaincodes are instantiated on peers
waitForChaincode "cli.org1.example.com" "peer0.org1.example.com:7061" "my-channel1" "chaincode1" "0.0.1"
waitForChaincode "cli.org2.example.com" "peer0.org2.example.com:7081" "my-channel1" "chaincode1" "0.0.1"
waitForChaincode "cli.org1.example.com" "peer1.org1.example.com:7062" "my-channel2" "chaincode2" "0.0.1"
waitForChaincode "cli.org2.example.com" "peer1.org2.example.com:7082" "my-channel2" "chaincode2" "0.0.1"
waitForChaincode "peer0.org1.example.com" "my-channel1" "chaincode1" "0.0.1"
waitForChaincode "peer0.org2.example.com" "my-channel1" "chaincode1" "0.0.1"
waitForChaincode "peer1.org1.example.com" "my-channel2" "chaincode2" "0.0.1"
waitForChaincode "peer1.org2.example.com" "my-channel2" "chaincode2" "0.0.1"

fablo_rest_org1="localhost:8802"

Expand All @@ -107,13 +109,13 @@ expectInvokeCli "cli.org2.example.com" "peer1.org2.example.com:7082" "my-channel

# restart the network and wait for chaincodes
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" stop && "$FABLO_HOME/fablo.sh" start)
waitForChaincode "cli.org1.example.com" "peer0.org1.example.com:7061" "my-channel1" "chaincode1" "0.0.1"
waitForChaincode "cli.org2.example.com" "peer0.org2.example.com:7081" "my-channel1" "chaincode1" "0.0.1"
waitForChaincode "peer0.org1.example.com" "my-channel1" "chaincode1" "0.0.1"
waitForChaincode "peer0.org2.example.com" "my-channel1" "chaincode1" "0.0.1"

# upgrade chaincode
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" chaincode upgrade "chaincode1" "0.0.2")
waitForChaincode "cli.org1.example.com" "peer0.org1.example.com:7061" "my-channel1" "chaincode1" "0.0.2"
waitForChaincode "cli.org2.example.com" "peer0.org2.example.com:7081" "my-channel1" "chaincode1" "0.0.2"
waitForChaincode "peer0.org1.example.com" "my-channel1" "chaincode1" "0.0.2"
waitForChaincode "peer0.org2.example.com" "my-channel1" "chaincode1" "0.0.2"

# check if state is kept after update
expectInvokeRest "$fablo_rest_org1" "my-channel1" "chaincode1" \
Expand Down
8 changes: 5 additions & 3 deletions e2e-network/docker/test-04-snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ TEST_TMP="$(rm -rf "$0.tmpdir" && mkdir -p "$0.tmpdir" && (cd "$0.tmpdir" && pwd
TEST_LOGS="$(mkdir -p "$0.logs" && (cd "$0.logs" && pwd))"
FABLO_HOME="$TEST_TMP/../../.."

export FABLO_HOME

CONFIG="$FABLO_HOME/samples/fablo-config-hlf2-1org-1chaincode-raft-explorer.json"

networkUp() {
Expand All @@ -30,7 +32,7 @@ waitForContainer() {
}

waitForChaincode() {
sh "$TEST_TMP/../wait-for-chaincode-tls.sh" "$1" "$2" "$3" "$4" "$5"
(cd "$TEST_TMP" && sh ../wait-for-chaincode.sh "$1" "$2" "$3" "$4")
}

expectInvokeRest() {
Expand All @@ -55,7 +57,7 @@ waitForContainer "couchdb.peer0.org1.example.com" "Apache CouchDB has started. T
waitForContainer "peer0.org1.example.com" "Joining gossip network of channel my-channel1 with 1 organizations"
waitForContainer "db.explorer.example.com" "database system is ready to accept connections" "200"
waitForContainer "explorer.example.com" "Successfully created channel event hub for \[my-channel1\]" "200"
waitForChaincode "cli.org1.example.com" "peer0.org1.example.com:7041" "my-channel1" "chaincode1" "0.0.1"
waitForChaincode "peer0.org1.example.com" "my-channel1" "chaincode1" "0.0.1"

fablo_rest_org1="localhost:8801"
snapshot_name="fablo-snapshot-$(date -u +"%Y%m%d%H%M%S")"
Expand Down Expand Up @@ -111,7 +113,7 @@ hook_command="perl -i -pe 's/FABRIC_VERSION=2\.3\.3/FABRIC_VERSION=2\.4\.2/g' ./
"$FABLO_HOME/fablo.sh" restore "$snapshot_name" "$hook_command" &&
"$FABLO_HOME/fablo.sh" start
)
waitForChaincode "cli.org1.example.com" "peer0.org1.example.com:7041" "my-channel1" "chaincode1" "0.0.1"
waitForChaincode "peer0.org1.example.com" "my-channel1" "chaincode1" "0.0.1"

sleep 5

Expand Down
36 changes: 0 additions & 36 deletions e2e-network/docker/wait-for-chaincode-tls.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2778,8 +2778,20 @@ peerChaincodeList() {
}
peerChaincodeListTls() {
echo \\"Chaincode list with TLS is not supported yet\\"
exit 1
local CLI_NAME=$1
local PEER_ADDRESS=$2
local CHANNEL_NAME=$3
local CA_CERT=$4
echo \\"Chaincodes list:\\"
inputLog \\"PEER_ADDRESS: $PEER_ADDRESS\\"
inputLog \\"CHANNEL_NAME: $CHANNEL_NAME\\"
inputLog \\"CA_CERT: $CA_CERT\\"
docker exec -e CORE_PEER_ADDRESS=\\"$PEER_ADDRESS\\" \\"$CLI_NAME\\" peer lifecycle chaincode querycommitted \\\\
--channelID \\"$CHANNEL_NAME\\" \\\\
--tls \\\\
--cafile \\"/var/hyperledger/cli/$CA_CERT\\"
}
"
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2656,8 +2656,20 @@ peerChaincodeList() {
}
peerChaincodeListTls() {
echo \\"Chaincode list with TLS is not supported yet\\"
exit 1
local CLI_NAME=$1
local PEER_ADDRESS=$2
local CHANNEL_NAME=$3
local CA_CERT=$4
echo \\"Chaincodes list:\\"
inputLog \\"PEER_ADDRESS: $PEER_ADDRESS\\"
inputLog \\"CHANNEL_NAME: $CHANNEL_NAME\\"
inputLog \\"CA_CERT: $CA_CERT\\"
docker exec -e CORE_PEER_ADDRESS=\\"$PEER_ADDRESS\\" \\"$CLI_NAME\\" peer lifecycle chaincode querycommitted \\\\
--channelID \\"$CHANNEL_NAME\\" \\\\
--tls \\\\
--cafile \\"/var/hyperledger/cli/$CA_CERT\\"
}
"
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4967,8 +4967,20 @@ peerChaincodeList() {
}

peerChaincodeListTls() {
echo \\"Chaincode list with TLS is not supported yet\\"
exit 1
local CLI_NAME=$1
local PEER_ADDRESS=$2
local CHANNEL_NAME=$3
local CA_CERT=$4

echo \\"Chaincodes list:\\"
inputLog \\"PEER_ADDRESS: $PEER_ADDRESS\\"
inputLog \\"CHANNEL_NAME: $CHANNEL_NAME\\"
inputLog \\"CA_CERT: $CA_CERT\\"

docker exec -e CORE_PEER_ADDRESS=\\"$PEER_ADDRESS\\" \\"$CLI_NAME\\" peer lifecycle chaincode querycommitted \\\\
--channelID \\"$CHANNEL_NAME\\" \\\\
--tls \\\\
--cafile \\"/var/hyperledger/cli/$CA_CERT\\"
}
"
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5466,8 +5466,20 @@ peerChaincodeList() {
}

peerChaincodeListTls() {
echo \\"Chaincode list with TLS is not supported yet\\"
exit 1
local CLI_NAME=$1
local PEER_ADDRESS=$2
local CHANNEL_NAME=$3
local CA_CERT=$4

echo \\"Chaincodes list:\\"
inputLog \\"PEER_ADDRESS: $PEER_ADDRESS\\"
inputLog \\"CHANNEL_NAME: $CHANNEL_NAME\\"
inputLog \\"CA_CERT: $CA_CERT\\"

docker exec -e CORE_PEER_ADDRESS=\\"$PEER_ADDRESS\\" \\"$CLI_NAME\\" peer lifecycle chaincode querycommitted \\\\
--channelID \\"$CHANNEL_NAME\\" \\\\
--tls \\\\
--cafile \\"/var/hyperledger/cli/$CA_CERT\\"
}
"
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,22 @@ peerChaincodeList() {
--channelID "$CHANNEL_NAME"
}


peerChaincodeListTls() {
echo "Chaincode list with TLS is not supported yet"
exit 1
local CLI_NAME=$1
local PEER_ADDRESS=$2
local CHANNEL_NAME=$3
local CA_CERT=$4

echo "Chaincodes list:"
inputLog "PEER_ADDRESS: $PEER_ADDRESS"
inputLog "CHANNEL_NAME: $CHANNEL_NAME"
inputLog "CA_CERT: $CA_CERT"


docker exec -e CORE_PEER_ADDRESS="$PEER_ADDRESS" "$CLI_NAME" peer lifecycle chaincode querycommitted \
--channelID "$CHANNEL_NAME" \
--tls \
--cafile "/var/hyperledger/cli/$CA_CERT"
}

0 comments on commit 128b524

Please sign in to comment.