From c4ad7d95ca81f7fcb2d62301b1b395ac44ab5244 Mon Sep 17 00:00:00 2001 From: Sam Yuan Date: Tue, 2 Apr 2024 20:48:34 +0800 Subject: [PATCH] update with review comments Signed-off-by: Sam Yuan --- test-network/scripts/configUpdate.sh | 5 +++++ test-network/scripts/envVar.sh | 5 +++++ test-network/scripts/org3-scripts/joinChannel.sh | 7 ++++++- test-network/scripts/org3-scripts/updateChannelConfig.sh | 7 ++++++- test-network/scripts/setAnchorPeer.sh | 8 +++++++- 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/test-network/scripts/configUpdate.sh b/test-network/scripts/configUpdate.sh index a49c77fd..a54d1410 100755 --- a/test-network/scripts/configUpdate.sh +++ b/test-network/scripts/configUpdate.sh @@ -6,6 +6,11 @@ # # import utils +# test network home var targets to test network folder +# the reason we use a var here is considering with org3 specific folder +# when invoking this for org3 as test-network/scripts/org3-scripts +# the value is changed from default as $PWD(test-network) +# to .. as relative path to make the import works test_network_home=${test_network_home:-${PWD}} . ${test_network_home}/scripts/envVar.sh diff --git a/test-network/scripts/envVar.sh b/test-network/scripts/envVar.sh index 752ec02c..c4b19b5a 100755 --- a/test-network/scripts/envVar.sh +++ b/test-network/scripts/envVar.sh @@ -8,6 +8,11 @@ # This is a collection of bash functions used by different scripts # imports +# test network home var targets to test network folder +# the reason we use a var here is considering with org3 specific folder +# when invoking this for org3 as test-network/scripts/org3-scripts +# the value is changed from default as $PWD(test-network) +# to .. as relative path to make the import works test_network_home=${test_network_home:-${PWD}} . ${test_network_home}/scripts/utils.sh diff --git a/test-network/scripts/org3-scripts/joinChannel.sh b/test-network/scripts/org3-scripts/joinChannel.sh index 94b2200c..b10c13c7 100755 --- a/test-network/scripts/org3-scripts/joinChannel.sh +++ b/test-network/scripts/org3-scripts/joinChannel.sh @@ -23,6 +23,11 @@ COUNTER=1 MAX_RETRY=5 # import environment variables +# test network home var targets to test network folder +# the reason we use a var here is considering with org3 specific folder +# when invoking this for org3 as test-network/scripts/org3-scripts +# the value is changed from default as $PWD(test-network) +# to .. as relative path to make the import works export test_network_home=.. . ${test_network_home}/scripts/envVar.sh @@ -48,7 +53,7 @@ joinChannel() { setAnchorPeer() { ORG=$1 - scripts/setAnchorPeer.sh $ORG $CHANNEL_NAME + ${test_network_home}/scripts/setAnchorPeer.sh $ORG $CHANNEL_NAME } setGlobalsCLI 3 diff --git a/test-network/scripts/org3-scripts/updateChannelConfig.sh b/test-network/scripts/org3-scripts/updateChannelConfig.sh index d8ba098b..c0d6b911 100755 --- a/test-network/scripts/org3-scripts/updateChannelConfig.sh +++ b/test-network/scripts/org3-scripts/updateChannelConfig.sh @@ -23,6 +23,11 @@ MAX_RETRY=5 # imports +# test network home var targets to test network folder +# the reason we use a var here is considering with org3 specific folder +# when invoking this for org3 as test-network/scripts/org3-scripts +# the value is changed from default as $PWD(test-network) +# to .. as relative path to make the import works export test_network_home=.. . ${test_network_home}/scripts/configUpdate.sh @@ -33,7 +38,7 @@ fetchChannelConfig 1 ${CHANNEL_NAME} config.json # Modify the configuration to append the new org set -x -jq -s '.[0] * {"channel_group":{"groups":{"Application":{"groups": {"Org3MSP":.[1]}}}}}' config.json ../organizations/peerOrganizations/org3.example.com/org3.json > modified_config.json +jq -s '.[0] * {"channel_group":{"groups":{"Application":{"groups": {"Org3MSP":.[1]}}}}}' config.json ${test_network_home}/organizations/peerOrganizations/org3.example.com/org3.json > modified_config.json { set +x; } 2>/dev/null # Compute a config update, based on the differences between config.json and modified_config.json, write it as a transaction to org3_update_in_envelope.pb diff --git a/test-network/scripts/setAnchorPeer.sh b/test-network/scripts/setAnchorPeer.sh index c1ab364f..39a073f2 100755 --- a/test-network/scripts/setAnchorPeer.sh +++ b/test-network/scripts/setAnchorPeer.sh @@ -6,7 +6,13 @@ # # import utils -. scripts/configUpdate.sh +# test network home var targets to test network folder +# the reason we use a var here is considering with org3 specific folder +# when invoking this for org3 as test-network/scripts/org3-scripts +# the value is changed from default as $PWD(test-network) +# to .. as relative path to make the import works +test_network_home=${test_network_home:-${PWD}} +. ${test_network_home}/scripts/configUpdate.sh # NOTE: this must be run in a CLI container since it requires jq and configtxlator