diff --git a/common/configtx/tool/configtxgen/main.go b/common/configtx/tool/configtxgen/main.go index af7a6e17161..3e1b575b9dd 100644 --- a/common/configtx/tool/configtxgen/main.go +++ b/common/configtx/tool/configtxgen/main.go @@ -44,6 +44,9 @@ var logger = flogging.MustGetLogger("common/configtx/tool") func doOutputBlock(config *genesisconfig.Profile, channelID string, outputBlock string) error { pgen := provisional.New(config) logger.Info("Generating genesis block") + if config.Orderer == nil { + return fmt.Errorf("config does not contain an Orderers section, necessary for all config blocks, aborting") + } if config.Consortiums == nil { logger.Warning("Genesis block does not contain a consortiums group definition. This block cannot be used for orderer bootstrap.") } diff --git a/common/configtx/tool/configtxgen/main_test.go b/common/configtx/tool/configtxgen/main_test.go index 3c10cec2da4..959be6c4ab8 100644 --- a/common/configtx/tool/configtxgen/main_test.go +++ b/common/configtx/tool/configtxgen/main_test.go @@ -51,6 +51,16 @@ func TestInspectBlock(t *testing.T) { assert.NoError(t, doInspectBlock(blockDest), "Good block inspection request") } +func TestMissingOrdererSection(t *testing.T) { + blockDest := tmpDir + string(os.PathSeparator) + "block" + + factory.InitFactories(nil) + config := genesisconfig.Load(genesisconfig.SampleInsecureProfile) + config.Orderer = nil + + assert.Error(t, doOutputBlock(config, "foo", blockDest), "Missing orderer section") +} + func TestInspectConfigTx(t *testing.T) { configTxDest := tmpDir + string(os.PathSeparator) + "configtx" diff --git a/common/configtx/tool/provisional/provisional.go b/common/configtx/tool/provisional/provisional.go index 074a92fb78b..3a0d283e57c 100644 --- a/common/configtx/tool/provisional/provisional.go +++ b/common/configtx/tool/provisional/provisional.go @@ -88,7 +88,6 @@ func New(conf *genesisconfig.Profile) Generator { // Chain Config Types config.DefaultHashingAlgorithm(), config.DefaultBlockDataHashingStructure(), - config.TemplateOrdererAddresses(conf.Orderer.Addresses), // TODO, move to conf.Channel when it exists // Default policies policies.TemplateImplicitMetaAnyPolicy([]string{}, configvaluesmsp.ReadersPolicyKey), @@ -99,6 +98,9 @@ func New(conf *genesisconfig.Profile) Generator { if conf.Orderer != nil { bs.ordererGroups = []*cb.ConfigGroup{ + // Orderer addresses + config.TemplateOrdererAddresses(conf.Orderer.Addresses), + // Orderer Config Types config.TemplateConsensusType(conf.Orderer.OrdererType), config.TemplateBatchSize(&ab.BatchSize{