mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
Fix test network chaincode deploy (#827)
Correctly check for installed chaincode and enable the same chaincode to be deployed on different channels Signed-off-by: James Taylor <jamest@uk.ibm.com> Signed-off-by: James Taylor <jamest@uk.ibm.com>
This commit is contained in:
parent
01da596ae1
commit
4eff55b75b
3 changed files with 10 additions and 6 deletions
|
|
@ -6,8 +6,11 @@ function installChaincode() {
|
|||
ORG=$1
|
||||
setGlobals $ORG
|
||||
set -x
|
||||
peer lifecycle chaincode install ${CC_NAME}.tar.gz >&log.txt
|
||||
res=$?
|
||||
peer lifecycle chaincode queryinstalled --output json | jq -r 'try (.installed_chaincodes[].package_id)' | grep ^${PACKAGE_ID}$ >&log.txt
|
||||
if test $? -ne 0; then
|
||||
peer lifecycle chaincode install ${CC_NAME}.tar.gz >&log.txt
|
||||
res=$?
|
||||
fi
|
||||
{ set +x; } 2>/dev/null
|
||||
cat log.txt
|
||||
verifyResult $res "Chaincode installation on peer0.org${ORG} has failed"
|
||||
|
|
@ -19,11 +22,10 @@ function queryInstalled() {
|
|||
ORG=$1
|
||||
setGlobals $ORG
|
||||
set -x
|
||||
peer lifecycle chaincode queryinstalled >&log.txt
|
||||
peer lifecycle chaincode queryinstalled --output json | jq -r 'try (.installed_chaincodes[].package_id)' | grep ^${PACKAGE_ID}$ >&log.txt
|
||||
res=$?
|
||||
{ set +x; } 2>/dev/null
|
||||
cat log.txt
|
||||
PACKAGE_ID=$(sed -n "/${CC_NAME}_${CC_VERSION}/{s/^Package ID: //; s/, Label:.*$//; p;}" log.txt)
|
||||
verifyResult $res "Query installed on peer0.org${ORG} has failed"
|
||||
successln "Query installed successful on peer0.org${ORG} on channel"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@ packageChaincode() {
|
|||
set -x
|
||||
peer lifecycle chaincode package ${CC_NAME}.tar.gz --path ${CC_SRC_PATH} --lang ${CC_RUNTIME_LANGUAGE} --label ${CC_NAME}_${CC_VERSION} >&log.txt
|
||||
res=$?
|
||||
PACKAGE_ID=$(peer lifecycle chaincode calculatepackageid ${CC_NAME}.tar.gz)
|
||||
{ set +x; } 2>/dev/null
|
||||
cat log.txt
|
||||
verifyResult $res "Chaincode packaging has failed"
|
||||
|
|
|
|||
|
|
@ -101,10 +101,11 @@ METADATA-EOF
|
|||
|
||||
tar -C "$tempdir/src" -czf "$tempdir/pkg/code.tar.gz" .
|
||||
tar -C "$tempdir/pkg" -czf "$CC_NAME.tar.gz" metadata.json code.tar.gz
|
||||
rm -Rf "$tempdir"
|
||||
rm -Rf "$tempdir"
|
||||
|
||||
PACKAGE_ID=$(peer lifecycle chaincode calculatepackageid ${CC_NAME}.tar.gz)
|
||||
|
||||
successln "Chaincode is packaged ${address}"
|
||||
|
||||
}
|
||||
|
||||
buildDockerImages() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue