Skip to content

Commit

Permalink
[FAB-4355] Fix consortium checking in configtxgen
Browse files Browse the repository at this point in the history
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 <baohyang@cn.ibm.com>
  • Loading branch information
yeasy committed Jun 5, 2017
1 parent 38d3879 commit d8c1a56
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion common/configtx/tool/configtxgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ func doOutputChannelCreateTx(conf *genesisconfig.Profile, channelID string, outp
}

if conf.Application == nil {
return fmt.Errorf("Cannot define a new channel with no application section")
return fmt.Errorf("Cannot define a new channel with no Application section")
}

if conf.Consortium == "" {
return fmt.Errorf("Cannot define a new channel with no Consortium section")
}

// XXX we ignore the non-application org names here, once the tool supports configuration updates
Expand Down
10 changes: 10 additions & 0 deletions common/configtx/tool/configtxgen/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ func TestMissingOrdererSection(t *testing.T) {
assert.Error(t, doOutputBlock(config, "foo", blockDest), "Missing orderer section")
}

func TestMissingConsortiumSection(t *testing.T) {
configTxDest := tmpDir + string(os.PathSeparator) + "configtx"

factory.InitFactories(nil)
config := genesisconfig.Load(genesisconfig.SampleSingleMSPChannelProfile)
config.Consortium = ""

assert.Error(t, doOutputChannelCreateTx(config, "foo", configTxDest), "Missing Consortium section in Application Profile definition")
}

func TestInspectConfigTx(t *testing.T) {
configTxDest := tmpDir + string(os.PathSeparator) + "configtx"

Expand Down

0 comments on commit d8c1a56

Please sign in to comment.