mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-22 09:35:10 +00:00
Use renamed CheckCommitReadiness function
FAB-16111 #done Change-Id: Iacdbd59515b71cb692935b0afbd1c678e0f55851 Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
This commit is contained in:
parent
750f937218
commit
583ff8f6d4
6 changed files with 64 additions and 62 deletions
|
|
@ -101,21 +101,23 @@ if [ "${NO_CHAINCODE}" != "true" ]; then
|
||||||
## approve the definition for org1
|
## approve the definition for org1
|
||||||
approveForMyOrg 1 0 1
|
approveForMyOrg 1 0 1
|
||||||
|
|
||||||
## simulate committing the chaincode definition, expect org1 to have approved and org2 not to
|
## check whether the chaincode definition is ready to be committed
|
||||||
simulateCommitChaincodeDefinition 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": false"
|
## expect org1 to have approved and org2 not to
|
||||||
simulateCommitChaincodeDefinition 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": false"
|
checkCommitReadiness 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": false"
|
||||||
|
checkCommitReadiness 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": false"
|
||||||
|
|
||||||
## now approve also for org2
|
## now approve also for org2
|
||||||
approveForMyOrg 1 0 2
|
approveForMyOrg 1 0 2
|
||||||
|
|
||||||
## simulate committing the chaincode definition again, expect them both to have approved
|
## check whether the chaincode definition is ready to be committed
|
||||||
simulateCommitChaincodeDefinition 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": true"
|
## expect them both to have approved
|
||||||
simulateCommitChaincodeDefinition 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": true"
|
checkCommitReadiness 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": true"
|
||||||
|
checkCommitReadiness 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": true"
|
||||||
|
|
||||||
## now that we know for sure both orgs have approved, commit the definition
|
## now that we know for sure both orgs have approved, commit the definition
|
||||||
commitChaincodeDefinition 1 0 1 0 2
|
commitChaincodeDefinition 1 0 1 0 2
|
||||||
|
|
||||||
## query on both orgs to see that the definition committed successfully
|
## query on both orgs to see that the definition committed successfully
|
||||||
queryCommitted 1 0 1
|
queryCommitted 1 0 1
|
||||||
queryCommitted 1 0 2
|
queryCommitted 1 0 2
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -211,14 +211,14 @@ commitChaincodeDefinition() {
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
# simulateCommitChaincodeDefinition VERSION PEER ORG
|
# checkCommitReadiness VERSION PEER ORG
|
||||||
simulateCommitChaincodeDefinition() {
|
checkCommitReadiness() {
|
||||||
VERSION=$1
|
VERSION=$1
|
||||||
PEER=$2
|
PEER=$2
|
||||||
ORG=$3
|
ORG=$3
|
||||||
shift 3
|
shift 3
|
||||||
setGlobals $PEER $ORG
|
setGlobals $PEER $ORG
|
||||||
echo "===================== Simulating the commit of the chaincode definition on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'... ===================== "
|
echo "===================== Checking the commit readiness of the chaincode definition on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME'... ===================== "
|
||||||
local rc=1
|
local rc=1
|
||||||
local starttime=$(date +%s)
|
local starttime=$(date +%s)
|
||||||
|
|
||||||
|
|
@ -228,9 +228,9 @@ simulateCommitChaincodeDefinition() {
|
||||||
test "$(($(date +%s) - starttime))" -lt "$TIMEOUT" -a $rc -ne 0
|
test "$(($(date +%s) - starttime))" -lt "$TIMEOUT" -a $rc -ne 0
|
||||||
do
|
do
|
||||||
sleep $DELAY
|
sleep $DELAY
|
||||||
echo "Attempting to simulate committing the chaincode definition on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
|
echo "Attempting to check the commit readiness of the chaincode definition on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
|
||||||
set -x
|
set -x
|
||||||
peer lifecycle chaincode simulatecommit --channelID $CHANNEL_NAME --name mycc $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --output json --init-required >&log.txt
|
peer lifecycle chaincode checkcommitreadiness --channelID $CHANNEL_NAME --name mycc $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --output json --init-required >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
test $res -eq 0 || continue
|
test $res -eq 0 || continue
|
||||||
|
|
@ -243,9 +243,9 @@ simulateCommitChaincodeDefinition() {
|
||||||
echo
|
echo
|
||||||
cat log.txt
|
cat log.txt
|
||||||
if test $rc -eq 0; then
|
if test $rc -eq 0; then
|
||||||
echo "===================== Simulating the commit of the chaincode definition successful on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' ===================== "
|
echo "===================== Checking the commit readiness of the chaincode definition successful on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' ===================== "
|
||||||
else
|
else
|
||||||
echo "!!!!!!!!!!!!!!! Simulate commit chaincode definition result on peer${PEER}.org${ORG} is INVALID !!!!!!!!!!!!!!!!"
|
echo "!!!!!!!!!!!!!!! Check commit readiness result on peer${PEER}.org${ORG} is INVALID !!!!!!!!!!!!!!!!"
|
||||||
echo "================== ERROR !!! FAILED to execute End-2-End Scenario =================="
|
echo "================== ERROR !!! FAILED to execute End-2-End Scenario =================="
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ setGlobals() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
simulateCommitChaincodeDefinition() {
|
checkCommitReadiness() {
|
||||||
VERSION=$1
|
VERSION=$1
|
||||||
PEER=$2
|
PEER=$2
|
||||||
ORG=$3
|
ORG=$3
|
||||||
|
|
@ -51,9 +51,9 @@ simulateCommitChaincodeDefinition() {
|
||||||
test "$(($(date +%s) - starttime))" -lt "$TIMEOUT" -a $rc -ne 0
|
test "$(($(date +%s) - starttime))" -lt "$TIMEOUT" -a $rc -ne 0
|
||||||
do
|
do
|
||||||
sleep $DELAY
|
sleep $DELAY
|
||||||
echo "Attempting to simulate committing the chaincode definition on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
|
echo "Attempting to check the commit readiness of the chaincode definition on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
|
||||||
set -x
|
set -x
|
||||||
peer lifecycle chaincode simulatecommit --channelID $CHANNEL_NAME --name $CC_NAME --signature-policy "OR('Org1MSP.peer', 'Org2MSP.peer')" --version ${VERSION} --init-required --sequence ${VERSION} >&log.txt
|
peer lifecycle chaincode checkcommitreadiness --channelID $CHANNEL_NAME --name $CC_NAME --signature-policy "OR('Org1MSP.peer', 'Org2MSP.peer')" --version ${VERSION} --init-required --sequence ${VERSION} >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
test $res -eq 0 || continue
|
test $res -eq 0 || continue
|
||||||
|
|
@ -66,9 +66,9 @@ simulateCommitChaincodeDefinition() {
|
||||||
echo
|
echo
|
||||||
cat log.txt
|
cat log.txt
|
||||||
if test $rc -eq 0; then
|
if test $rc -eq 0; then
|
||||||
echo "===================== Simulating the commit of the chaincode definition successful on peer${PEER}.org${ORG} ===================== "
|
echo "===================== Checking the commit readiness of the chaincode definition successful on peer${PEER}.org${ORG} ===================== "
|
||||||
else
|
else
|
||||||
echo "!!!!!!!!!!!!!!! Simulate commit chaincode definition result on peer${PEER}.org${ORG} is INVALID !!!!!!!!!!!!!!!!"
|
echo "!!!!!!!!!!!!!!! Check commit readiness result on peer${PEER}.org${ORG} is INVALID !!!!!!!!!!!!!!!!"
|
||||||
echo "================== ERROR !!! FAILED to execute End-2-End Scenario =================="
|
echo "================== ERROR !!! FAILED to execute End-2-End Scenario =================="
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
#
|
||||||
|
# Copyright IBM Corp All Rights Reserved
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
checkCommitReadiness() {
|
||||||
|
echo "===================== Check the commit readiness of the chaincode definition for ${CORE_PEER_LOCALMSPID} ===================== "
|
||||||
|
local rc=1
|
||||||
|
local starttime=$(date +%s)
|
||||||
|
|
||||||
|
# continue to poll
|
||||||
|
# we either get a successful response, or reach TIMEOUT
|
||||||
|
while
|
||||||
|
test "$(($(date +%s) - starttime))" -lt "$TIMEOUT" -a $rc -ne 0
|
||||||
|
do
|
||||||
|
echo "Attempting to check the commit readiness of the chaincode definition for ${CORE_PEER_LOCALMSPID} ...$(($(date +%s) - starttime)) secs"
|
||||||
|
set -x
|
||||||
|
peer lifecycle chaincode checkcommitreadiness -o irs-orderer:7050 --channelID irs --signature-policy "AND(OR('partya.peer','partyb.peer','partyc.peer'), 'auditor.peer')" --name irscc --version 1 --init-required --sequence 1 >&log.txt
|
||||||
|
res=$?
|
||||||
|
set +x
|
||||||
|
test $res -eq 0 || continue
|
||||||
|
let rc=0
|
||||||
|
for var in "$@"
|
||||||
|
do
|
||||||
|
grep "$var" log.txt &>/dev/null || let rc=1
|
||||||
|
done
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
cat log.txt
|
||||||
|
if test $rc -eq 0; then
|
||||||
|
echo "===================== Checking the commit readiness of the chaincode definition successful for ${CORE_PEER_LOCALMSPID} ===================== "
|
||||||
|
else
|
||||||
|
echo "!!!!!!!!!!!!!!! Check commit readiness result for ${CORE_PEER_LOCALMSPID} is INVALID !!!!!!!!!!!!!!!!"
|
||||||
|
echo "================== ERROR !!! FAILED to execute End-2-End Scenario =================="
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
@ -73,13 +73,13 @@ approveChaincode() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
simulateCommitChaincode() {
|
checkCommitReadiness() {
|
||||||
for org in partya partyb partyc auditor rrprovider
|
for org in partya partyb partyc auditor rrprovider
|
||||||
do
|
do
|
||||||
export CORE_PEER_LOCALMSPID=$org
|
export CORE_PEER_LOCALMSPID=$org
|
||||||
export CORE_PEER_ADDRESS=irs-$org:7051
|
export CORE_PEER_ADDRESS=irs-$org:7051
|
||||||
export CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/$org.example.com/users/Admin@$org.example.com/msp
|
export CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/$org.example.com/users/Admin@$org.example.com/msp
|
||||||
simulateCommit "\"partya\": true" "\"partyb\": true" "\"partyc\": true" "\"auditor\": true" "\"rrprovider\": true"
|
checkCommitReadiness "\"partya\": true" "\"partyb\": true" "\"partyc\": true" "\"auditor\": true" "\"rrprovider\": true"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -164,9 +164,9 @@ approveChaincode
|
||||||
|
|
||||||
. scripts/simulate-commit.sh
|
. scripts/simulate-commit.sh
|
||||||
|
|
||||||
# Simulate committing the chaincode definition
|
# Check the commit readiness of the chaincode definition
|
||||||
echo "Simulate committing the chaincode definition..."
|
echo "Checking the commit readiness of the chaincode definition..."
|
||||||
simulateCommitChaincode
|
checkCommitReadiness
|
||||||
|
|
||||||
# Commit chaincode definition
|
# Commit chaincode definition
|
||||||
echo "Committing chaincode definition..."
|
echo "Committing chaincode definition..."
|
||||||
|
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
#
|
|
||||||
# Copyright IBM Corp All Rights Reserved
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
simulateCommit() {
|
|
||||||
echo "===================== Simulating the commit of the chaincode definition for ${CORE_PEER_LOCALMSPID} ===================== "
|
|
||||||
local rc=1
|
|
||||||
local starttime=$(date +%s)
|
|
||||||
|
|
||||||
# continue to poll
|
|
||||||
# we either get a successful response, or reach TIMEOUT
|
|
||||||
while
|
|
||||||
test "$(($(date +%s) - starttime))" -lt "$TIMEOUT" -a $rc -ne 0
|
|
||||||
do
|
|
||||||
echo "Attempting to simulate committing the chaincode definition for ${CORE_PEER_LOCALMSPID} ...$(($(date +%s) - starttime)) secs"
|
|
||||||
set -x
|
|
||||||
peer lifecycle chaincode simulatecommit -o irs-orderer:7050 --channelID irs --signature-policy "AND(OR('partya.peer','partyb.peer','partyc.peer'), 'auditor.peer')" --name irscc --version 1 --init-required --sequence 1 >&log.txt
|
|
||||||
res=$?
|
|
||||||
set +x
|
|
||||||
test $res -eq 0 || continue
|
|
||||||
let rc=0
|
|
||||||
for var in "$@"
|
|
||||||
do
|
|
||||||
grep "$var" log.txt &>/dev/null || let rc=1
|
|
||||||
done
|
|
||||||
done
|
|
||||||
echo
|
|
||||||
cat log.txt
|
|
||||||
if test $rc -eq 0; then
|
|
||||||
echo "===================== Simulating the commit of the chaincode definition successful for ${CORE_PEER_LOCALMSPID} ===================== "
|
|
||||||
else
|
|
||||||
echo "!!!!!!!!!!!!!!! Simulate commit chaincode definition result for ${CORE_PEER_LOCALMSPID} is INVALID !!!!!!!!!!!!!!!!"
|
|
||||||
echo "================== ERROR !!! FAILED to execute End-2-End Scenario =================="
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue