Skip to content

Commit

Permalink
Successfully pass the tests
Browse files Browse the repository at this point in the history
Signed-off-by: Sanket <telisanket2002@gmail.com>
  • Loading branch information
Sanket-0510 committed Nov 13, 2024
1 parent c399ca8 commit 16c2f02
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 93 deletions.
25 changes: 8 additions & 17 deletions e2e-network/docker/test-05.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-hlf3-1orgs-1chaincode.json"

networkUp() {
Expand Down Expand Up @@ -36,7 +38,7 @@ waitForChaincode() {
}

expectInvoke() {
(cd "$TEST_TMP" && sh ../expect-invoke-cli.sh "$1" "$2" "$3" "$4" "$5" "$6")
(cd "$TEST_TMP" && sh ../expect-invoke-cli.sh "$1" "$2" "$3" "$4" "$5" "")
}

expectCommand() {
Expand All @@ -49,8 +51,8 @@ trap 'networkDown ; echo "Test failed" ; exit 1' ERR SIGINT
# start the network
networkUp

waitForContainer "orderer0.group1.orderer.example.com" "Created and started new.*my-channel1"
waitForContainer "ca.org1.example.com" "Listening on http://0.0.0.0:7054"
waitForContainer "orderer0.group1.orderer.example.com" "Starting raft node as part of a new channel channel=my-channel1"
waitForContainer "ca.org1.example.com" "Listening on https://0.0.0.0:7054"
waitForContainer "peer0.org1.example.com" "Joining gossip network of channel my-channel1 with 1 organizations"
waitForContainer "peer1.org1.example.com" "Joining gossip network of channel my-channel1 with 1 organizations"
waitForContainer "peer0.org1.example.com" "Learning about the configured anchor peers of Org1MSP for channel my-channel1"
Expand All @@ -71,23 +73,12 @@ expectInvoke "peer1.org1.example.com" "my-channel1" "chaincode1" \
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" channel fetch newest my-channel1 org1 peer1)
expectCommand "cat \"$TEST_TMP/newest.block\"" "KVContract:get"

(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" channel fetch 4 my-channel1 org1 peer1 "another.block")
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" channel fetch 3 my-channel1 org1 peer1 "another.block")
expectCommand "cat \"$TEST_TMP/another.block\"" "KVContract:put"

(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" channel fetch config my-channel1 org1 peer1 "channel-config.json")
expectCommand "cat \"$TEST_TMP/channel-config.json\"" "\"mod_policy\": \"Admins\","

expectCommand "(cd \"$TEST_TMP\" && \"$FABLO_HOME/fablo.sh\" channel getinfo my-channel1 org1 peer1)" "\"height\":6"
expectCommand "(cd \"$TEST_TMP\" && \"$FABLO_HOME/fablo.sh\" channel getinfo my-channel1 org1 peer1)" "\"height\":5"

# Reset and ensure the state is lost after reset
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" reset)
waitForChaincode "peer0.org1.example.com" "my-channel1" "chaincode1" "0.0.1"
waitForChaincode "peer1.org1.example.com" "my-channel1" "chaincode1" "0.0.1"
expectInvoke "peer0.org1.example.com" "my-channel1" "chaincode1" \
'{"Args":["KVContract:get", "name"]}' \
'{\"error\":\"NOT_FOUND\"}'

# Put some data again
expectInvoke "peer0.org1.example.com" "my-channel1" "chaincode1" \
'{"Args":["KVContract:put", "name", "James Bond"]}' \
'{\"success\":\"OK\"}'
echo "🎉 Test passed! 🎉"
2 changes: 1 addition & 1 deletion src/setup-docker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export default class SetupDockerGenerator extends Generator {
}

_copyUtilityScripts(capabilities: Capabilities): void {
this.fs.copyTpl(this.templatePath(`fabric-docker-${capabilities.isV3? "v3": "v2"}.sh`), this.destinationPath("fabric-docker.sh"));
this.fs.copyTpl(this.templatePath(`fabric-docker.sh`), this.destinationPath("fabric-docker.sh"));

this.fs.copyTpl(
this.templatePath(`fabric-docker/scripts/cli/channel_fns-${capabilities.isV3? "v3": "v2"}.sh`),
Expand Down
65 changes: 0 additions & 65 deletions src/setup-docker/templates/fabric-docker-v3.sh

This file was deleted.

File renamed without changes.
13 changes: 12 additions & 1 deletion src/setup-docker/templates/fabric-docker/commands-generated.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ generateArtifacts() {
<% }) -%>
<%_ ordererGroups.forEach((ordererGroup) => { _%>
<% if(!global.capabilities.isV3) {%>
printItalics "Generating genesis block for group <%= ordererGroup.name %>" "U1F3E0"
genesisBlockCreate "$FABLO_NETWORK_ROOT/fabric-config" "$FABLO_NETWORK_ROOT/fabric-config/config" "<%= ordererGroup.profileName %>"
<% } else { %>
echo "System channel not supported for Fabric version 3"
<% } %>
<%_ }) _%>
# Create directory for chaincode packages to avoid permission errors on linux
mkdir -p "$FABLO_NETWORK_ROOT/fabric-config/chaincode-packages"
Expand Down Expand Up @@ -179,6 +184,7 @@ upgradeChaincode() {
}
notifyOrgsAboutChannels() {
<% if(!global.capabilities.isV3) { %>
printHeadline "Creating new channel config blocks" "U1F537"
<% channels.forEach((channel) => { -%>
<% channel.orgs.forEach((org) => { -%>
Expand Down Expand Up @@ -219,6 +225,11 @@ notifyOrgsAboutChannels() {
deleteNewChannelUpdateTx "<%= channel.name %>" "<%= org.mspName %>" "<%= org.cli.address %>"
<% }) -%>
<% }) -%>
<% } else { %>
echo ""
<% } %>
}
printStartSuccessInfo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ createChannelTx() {
local CONFIG_PATH=$2
local CONFIG_PROFILE=$3
local OUTPUT_PATH=$4
local CHANNEL_TX_PATH="$OUTPUT_PATH/$CHANNEL_NAME".pb
local CHANNEL_TX_PATH="$OUTPUT_PATH/$CHANNEL_NAME.pb"
echo CHNANEL_TX_PATH: $CHANNEL_TX_PATH

echo "Creating channelTx for $CHANNEL_NAME..."
inputLog "CONFIG_PATH: $CONFIG_PATH"
Expand All @@ -91,17 +92,20 @@ createChannelTx() {
exit 1
fi

docker run -i -d -w="/" --name $CONTAINER_NAME hyperledger/fabric-tools:"${FABRIC_VERSION}" bash || removeContainer $CONTAINER_NAME
docker cp "$CONFIG_PATH" $CONTAINER_NAME:/fabric-config || removeContainer $CONTAINER_NAME

docker exec -i $CONTAINER_NAME mkdir /config || removeContainer $CONTAINER_NAME
docker run --rm \
--name $CONTAINER_NAME \
-v "$CONFIG_PATH":/fabric-config \
-v "$OUTPUT_PATH":/output \
hyperledger/fabric-tools:"${FABRIC_VERSION}" \
bash -c "mkdir -p /output && configtxgen --configPath /fabric-config -profile ${CONFIG_PROFILE} -outputBlock /output/$CHANNEL_NAME.pb -channelID ${CHANNEL_NAME}"

docker exec -i $CONTAINER_NAME configtxgen --configPath ./fabric-config -profile "${CONFIG_PROFILE}" -outputBlock ./config/channel.pb -channelID "${CHANNEL_NAME}"
docker cp $CONTAINER_NAME:/config/channel.pb "$CHANNEL_TX_PATH" || removeContainer $CONTAINER_NAME

if [ $? -ne 0 ]; then
echo "Failed to create channel configuration transaction."
exit 1
fi

echo "Channel configuration created at $CHANNEL_TX_PATH"

removeContainer $CONTAINER_NAME
}

createNewChannelUpdateTx() {
Expand Down

0 comments on commit 16c2f02

Please sign in to comment.