Skip to content

Commit

Permalink
[FAB-18054] Remove default value for top level orderer addresses if (#…
Browse files Browse the repository at this point in the history
…1550)

unset in config

* Top level orderer addresses are deprecated in 2.2 so this commit
removes the default value for consumers that pass a config with no
orderer addresses value

Signed-off-by: Danny Cao <dcao@us.ibm.com>
(cherry picked from commit ff39bf9)
  • Loading branch information
caod123 authored and Brett Logan committed Jul 8, 2020
1 parent ff00d9b commit 9c3c599
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions common/channelconfig/realconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func TestWithRealConfigtx(t *testing.T) {
func TestOrgSpecificOrdererEndpoints(t *testing.T) {
t.Run("Without_Capability", func(t *testing.T) {
conf := genesisconfig.Load(genesisconfig.SampleDevModeSoloProfile, configtest.GetDevConfigDir())
conf.Orderer.Addresses = []string{"127.0.0.1:7050"}
conf.Capabilities = map[string]bool{"V1_3": true}

cg, err := encoder.NewChannelGroup(conf)
Expand Down
5 changes: 4 additions & 1 deletion discovery/support/config/support_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,10 @@ func injectGlobalOrdererEndpoint(t *testing.T, block *common.Block, endpoint str
confEnv, err := configtx.UnmarshalConfigEnvelope(payload.Data)
assert.NoError(t, err)
// Replace the orderer addresses
confEnv.Config.ChannelGroup.Values[ordererAddresses.Key()].Value = protoutil.MarshalOrPanic(ordererAddresses.Value())
confEnv.Config.ChannelGroup.Values[ordererAddresses.Key()] = &common.ConfigValue{
Value: protoutil.MarshalOrPanic(ordererAddresses.Value()),
ModPolicy: "/Channel/Orderer/Admins",
}
// Remove the per org addresses, if applicable
ordererGrps := confEnv.Config.ChannelGroup.Groups[channelconfig.OrdererGroupKey].Groups
for _, grp := range ordererGrps {
Expand Down
4 changes: 0 additions & 4 deletions internal/configtxgen/genesisconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ type Kafka struct {
var genesisDefaults = TopLevel{
Orderer: &Orderer{
OrdererType: "solo",
Addresses: []string{"127.0.0.1:7050"},
BatchTimeout: 2 * time.Second,
BatchSize: BatchSize{
MaxMessageCount: 500,
Expand Down Expand Up @@ -315,9 +314,6 @@ loop:
case ord.OrdererType == "":
logger.Infof("Orderer.OrdererType unset, setting to %v", genesisDefaults.Orderer.OrdererType)
ord.OrdererType = genesisDefaults.Orderer.OrdererType
case ord.Addresses == nil:
logger.Infof("Orderer.Addresses unset, setting to %s", genesisDefaults.Orderer.Addresses)
ord.Addresses = genesisDefaults.Orderer.Addresses
case ord.BatchTimeout == 0:
logger.Infof("Orderer.BatchTimeout unset, setting to %s", genesisDefaults.Orderer.BatchTimeout)
ord.BatchTimeout = genesisDefaults.Orderer.BatchTimeout
Expand Down
3 changes: 1 addition & 2 deletions internal/peer/chaincode/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ func TestGetOrdererEndpointFromConfigTx(t *testing.T) {
ordererEndpoints, err := common.GetOrdererEndpointOfChain(mockchain, signer, mockEndorserClient, cryptoProvider)
assert.NoError(t, err, "GetOrdererEndpointOfChain from genesis block")

assert.Equal(t, len(ordererEndpoints), 1)
assert.Equal(t, ordererEndpoints[0], "127.0.0.1:7050")
assert.Equal(t, len(ordererEndpoints), 0)
}

func TestGetOrdererEndpointFail(t *testing.T) {
Expand Down
5 changes: 4 additions & 1 deletion orderer/common/cluster/replication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,10 @@ func injectGlobalOrdererEndpoint(t *testing.T, block *common.Block, endpoint str
confEnv, err := configtx.UnmarshalConfigEnvelope(payload.Data)
assert.NoError(t, err)
// Replace the orderer addresses
confEnv.Config.ChannelGroup.Values[ordererAddresses.Key()].Value = protoutil.MarshalOrPanic(ordererAddresses.Value())
confEnv.Config.ChannelGroup.Values[ordererAddresses.Key()] = &common.ConfigValue{
Value: protoutil.MarshalOrPanic(ordererAddresses.Value()),
ModPolicy: "/Channel/Orderer/Admins",
}
// Remove the per org addresses, if applicable
ordererGrps := confEnv.Config.ChannelGroup.Groups[channelconfig.OrdererGroupKey].Groups
for _, grp := range ordererGrps {
Expand Down

0 comments on commit 9c3c599

Please sign in to comment.