hyperledger-labs / fablo

Fablo is a simple tool to generate the Hyperledger Fabric blockchain network and run it on Docker. It supports RAFT and solo consensus protocols, multiple organizations and channels, chaincode installation and upgrade.
Apache License 2.0
188 stars 72 forks source link

Support chaincode list command #406

Open dzikowski opened 10 months ago

dzikowski commented 10 months ago

Right now we use some scripts in e2e-network directory to determine chaincode list, like in wait-for-chaincode.sh. The goal of this issue is to support the following command for Docker engine:

fablo chaincode list <peer> <channel>

Implementation details

Add to fabric-docker.sh:

elif [ "$1" = "chaincodes" ] && [ "$2" = "list" ]; then
  chaincodeList "$3" "$4"

Use the syntax known from channel query scripts for chaincode-scripts.sh; something similar to:

chaincodeList() {
if [ "$#" -ne 3 ]; then
  echo "Expected 3 parameters for chaincode list, but got: $@"
  exit 1
<% orgs.forEach((org) => { org.peers.forEach((peer) => { %>
elif [ "$1" = "<%= org.name.toLowerCase(); %>" ] && [ "$2" = "<%= peer.name %>" ]; then
  <% if(!global.tls) { %>
    peerChaincodeList "<%= org.cli.address %>" "<%= peer.fullAddress %>" "$3" # $3 is channel name
  <% } else { %>
    peerChaincodeListTls "<%= org.cli.address %>" "<%= peer.fullAddress %>" "#3" # ??? maybe a TLS file path will be required inside target function
  <% } %>
<% })}) %>
}

Inside wait-for-chaincode.sh use:

listChaincodes() {
  "$FABLO_HOME/fablo.sh" chaincode list "$peer" "$channel"
  # instead of previous:
  #  docker exec -e CORE_PEER_ADDRESS="$peer" "$cli" peer lifecycle chaincode querycommitted \
  #    --channelID "$channel"
}

Add peerChaincodeList, and peerChaincodeListTls functions to chaincode-functions-v2.sh file.

Steps

  1. Support non-TLS flow (test-01)
  2. Support TLS (test-02)
  3. Update README with docs + update CHANGELOG

Can be implemented in separate PRs

Hejwo commented 10 months ago

@jnjerin current work - For some reason we cannot assign her