Skip to content

Commit 71cd6f6

Browse files
author
Jason Yellick
committed
[FAB-4428] Check for read error on inspect tx
There was a missing error check when reading a channel create tx from disk to inspect it, resulting in a confusing error later in the flow. Change-Id: I3b0189d6c41f59bf524ce2b3fd43111140af75a3 Signed-off-by: Jason Yellick <[email protected]>
1 parent 85ef083 commit 71cd6f6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

common/configtx/tool/configtxgen/main.go

+4
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ func configGroupAsJSON(group *cb.ConfigGroup) (string, error) {
241241
func doInspectChannelCreateTx(inspectChannelCreateTx string) error {
242242
logger.Info("Inspecting transaction")
243243
data, err := ioutil.ReadFile(inspectChannelCreateTx)
244+
if err != nil {
245+
return fmt.Errorf("could not read channel create tx: %s", err)
246+
}
247+
244248
logger.Info("Parsing transaction")
245249
env, err := utils.UnmarshalEnvelope(data)
246250
if err != nil {

common/configtx/tool/configtxgen/main_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ func TestMissingConsortiumSection(t *testing.T) {
7272
assert.Error(t, doOutputChannelCreateTx(config, "foo", configTxDest), "Missing Consortium section in Application Profile definition")
7373
}
7474

75+
func TestInspectMissingConfigTx(t *testing.T) {
76+
assert.Error(t, doInspectChannelCreateTx("ChannelCreateTxFileWhichDoesn'tReallyExist"), "Missing channel create tx file")
77+
}
78+
7579
func TestInspectConfigTx(t *testing.T) {
7680
configTxDest := tmpDir + string(os.PathSeparator) + "configtx"
7781

0 commit comments

Comments
 (0)