Skip to content

Commit d8c1a56

Browse files
committed
[FAB-4355] Fix consortium checking in configtxgen
Configtxgen requires a Consortium config in generating ChannelCreateTX. Existing code does not check that and will break by taking the default empty value. This patchset helps fix it by add the checking. One test case is also included. Change-Id: I8a205627f8a54c462478e9d8d0d5abbc34d36755 Signed-off-by: Baohua Yang <[email protected]>
1 parent 38d3879 commit d8c1a56

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

common/configtx/tool/configtxgen/main.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ func doOutputChannelCreateTx(conf *genesisconfig.Profile, channelID string, outp
6868
}
6969

7070
if conf.Application == nil {
71-
return fmt.Errorf("Cannot define a new channel with no application section")
71+
return fmt.Errorf("Cannot define a new channel with no Application section")
72+
}
73+
74+
if conf.Consortium == "" {
75+
return fmt.Errorf("Cannot define a new channel with no Consortium section")
7276
}
7377

7478
// XXX we ignore the non-application org names here, once the tool supports configuration updates

common/configtx/tool/configtxgen/main_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ func TestMissingOrdererSection(t *testing.T) {
6262
assert.Error(t, doOutputBlock(config, "foo", blockDest), "Missing orderer section")
6363
}
6464

65+
func TestMissingConsortiumSection(t *testing.T) {
66+
configTxDest := tmpDir + string(os.PathSeparator) + "configtx"
67+
68+
factory.InitFactories(nil)
69+
config := genesisconfig.Load(genesisconfig.SampleSingleMSPChannelProfile)
70+
config.Consortium = ""
71+
72+
assert.Error(t, doOutputChannelCreateTx(config, "foo", configTxDest), "Missing Consortium section in Application Profile definition")
73+
}
74+
6575
func TestInspectConfigTx(t *testing.T) {
6676
configTxDest := tmpDir + string(os.PathSeparator) + "configtx"
6777

0 commit comments

Comments
 (0)