@@ -291,25 +291,6 @@ func TestValidateConfigEnvelope(t *testing.T) {
291
291
},
292
292
containsError : "field Config.ChannelGroup.Values is nil" ,
293
293
},
294
- {
295
- name : "no OrdererAddressesKey in ChannelGroup Values" ,
296
- ce : & common.ConfigEnvelope {
297
- Config : & common.Config {
298
- ChannelGroup : & common.ConfigGroup {
299
- Values : map [string ]* common.ConfigValue {},
300
- Groups : map [string ]* common.ConfigGroup {
301
- channelconfig .ApplicationGroupKey : {
302
- Groups : map [string ]* common.ConfigGroup {},
303
- },
304
- channelconfig .OrdererGroupKey : {
305
- Groups : map [string ]* common.ConfigGroup {},
306
- },
307
- },
308
- },
309
- },
310
- },
311
- containsError : "field Config.ChannelGroup.Values is empty" ,
312
- },
313
294
}
314
295
315
296
for _ , test := range tests {
@@ -341,7 +322,7 @@ func TestOrdererEndpoints(t *testing.T) {
341
322
}, res .Orderers )
342
323
})
343
324
344
- t .Run ("Per org endpoints" , func (t * testing.T ) {
325
+ t .Run ("Per org endpoints alongside global endpoints " , func (t * testing.T ) {
345
326
block , err := test .MakeGenesisBlock ("mychannel" )
346
327
assert .NoError (t , err )
347
328
@@ -361,6 +342,42 @@ func TestOrdererEndpoints(t *testing.T) {
361
342
"aBadOrg" : {},
362
343
}, res .Orderers )
363
344
})
345
+
346
+ t .Run ("Per org endpoints without global endpoints" , func (t * testing.T ) {
347
+ block , err := test .MakeGenesisBlock ("mychannel" )
348
+ assert .NoError (t , err )
349
+
350
+ fakeBlockGetter := & mocks.ConfigBlockGetter {}
351
+ cs := config .NewDiscoverySupport (fakeBlockGetter )
352
+
353
+ fakeBlockGetter .GetCurrConfigBlockReturnsOnCall (0 , block )
354
+
355
+ removeGlobalEndpoints (t , block )
356
+ injectAdditionalEndpointPair (t , block , "perOrgEndpoint:7050" , "SampleOrg" )
357
+ injectAdditionalEndpointPair (t , block , "endpointWithoutAPortName" , "aBadOrg" )
358
+
359
+ res , err := cs .Config ("test" )
360
+ assert .NoError (t , err )
361
+ assert .Equal (t , map [string ]* discovery.Endpoints {
362
+ "SampleOrg" : {Endpoint : []* discovery.Endpoint {{Host : "perOrgEndpoint" , Port : 7050 }}},
363
+ "aBadOrg" : {},
364
+ }, res .Orderers )
365
+ })
366
+ }
367
+
368
+ func removeGlobalEndpoints (t * testing.T , block * common.Block ) {
369
+ // Unwrap the layers until we reach the orderer addresses
370
+ env , err := protoutil .ExtractEnvelope (block , 0 )
371
+ assert .NoError (t , err )
372
+ payload := protoutil .UnmarshalPayloadOrPanic (env .Payload )
373
+ confEnv , err := configtx .UnmarshalConfigEnvelope (payload .Data )
374
+ assert .NoError (t , err )
375
+ // Remove the orderer addresses
376
+ delete (confEnv .Config .ChannelGroup .Values , channelconfig .OrdererAddressesKey )
377
+ // And put it back into the block
378
+ payload .Data = protoutil .MarshalOrPanic (confEnv )
379
+ env .Payload = protoutil .MarshalOrPanic (payload )
380
+ block .Data .Data [0 ] = protoutil .MarshalOrPanic (env )
364
381
}
365
382
366
383
func injectGlobalOrdererEndpoint (t * testing.T , block * common.Block , endpoint string ) {
0 commit comments