Open dzikowski opened 1 year ago
The second step for this command after #403 is to ensure we have consistent API - the same as for chaincode list #406 and we use generators to make it work with custom network topologies.
Checklist for the second step:
chaincodeInvoke
in chaincode-scripts.sh
should use generators as in the listing belowpeerChaincodeInvoke
should be added to chaincode-functions-v2.sh
chaincodeInvoke
in chaincode-scripts.sh
should use peerChaincodeInvoke
to invoke chaincodespeerChaincodeInvoke
should be able to call multiple peers (it should include the part: PEER_ADDRESSES="--peerAddresses $(echo "$PEERS" | sed 's/,/ --peerAddresses /g')"
)peerChaincodeInvokeTls
should be added to chaincode-functions-v2.sh
expect-invoke-cli-tls.sh
file should be removed. test-02-raft-2orgs.sh
should use expect-invoke-cli.sh
insteadSuggested implementation for chaincodeInvoke()
in chaincode-scripts.sh
:
# Function to perform chaincode invoke. Accepts 5 parameters:
# 1. comma-separated peers
# 2. channel name
# 3. chaincode name
# 4. chaincode command
# 5. transient data (optional)
chaincodeInvoke() {
if [ "$#" -ne 4 ] && [ "$#" -ne 5 ]; then
echo "Expected 4 or 5 parameters for chaincode list, but got: $*"
echo "Usage: fablo chaincode invoke <peer_domains_comma_separated> <channel_name> <chaincode_name> <command> [transient]"
exit 1
fi
cli=""
peer_addresses=""
<% if (!global.tls) { %>
peer_certs=""
<% } %>
<% orgs.forEach((org) => { -%>
<% org.peers.forEach((peer) => { -%>
if [[ "$1" == *"<%= peer.address %>"* ]]; then
cli="<%= org.cli.address %>"
peer_addresses="$peer_addresses,<%= peer.fullAddress %>"
<% if(!global.tls) { %>
peer_certs="$peer_certs,crypto/peers/<%= peer.address %>/tls/ca.crt"
<% } %>
fi
<% }) -%>
<% }) -%>
if [ -z "$peer_addresses" ]; then
echo "Unknown peers: $1"
exit 1
fi
<% if(!global.tls) { %>
peerChaincodeInvoke "$cli" "${peer_addresses:1}" "$2" "$3" "$4" "$5"
<% } else { %>
peerChaincodeInvokeTls "$cli" "${peer_addresses:1}" "$2" "$3" "$4" "$5" "${peer_certs:1}"
<% } %>
}
Right now we have a buch of test scripts to verify if invoking chaincodes work (
e2e-network/expect-invoke-cli.sh
and similar). For the simplest Docker setup it is handled by executing some operations on the CLI container:We want invoke command to be supported by Fablo, with the syntax similar to our channel query scripts. Within this issue we want to support invoke command for the simplest use case: no TLS, Docker setup, and using CLI container. Relevant script is
expect-invoke-cli.sh
. After this issue, the script, instead of invoking docker, should call(some path)/fablo.sh chaincode invoke (some params)
.Probably the best way to implement this is to follow the similar approach as for channel query scripts - using templates and strong validation.
Desired syntax:
Sample:
No need for additional tests. In order to verify the code works we just want to replace the content of
expect-invoke-cli.sh
script.This issue, however includes upgrade of README.
Further steps: