Skip to content

Commit

Permalink
[FAB-9983] fixing endpointconfig channels
Browse files Browse the repository at this point in the history
-Handling condition where no channel config
found for given channel ID.
-Changes needed from abondoned code push
related to FAB-10001

Change-Id: If74e8c05e60363ddcda686e91b03def60cce05d7
Signed-off-by: Sudesh Shetty <sudesh.shetty@securekey.com>
  • Loading branch information
sudeshrshetty committed May 15, 2018
1 parent 5ac2d97 commit dd2868a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/fab/channel/transactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ func orderersFromChannel(ctx context.Client, channelID string) ([]fab.Orderer, e

chNetworkConfig, err := ctx.EndpointConfig().ChannelConfig(channelID)
if err != nil {
s, ok := status.FromError(err)
if ok && s.Code == status.NoMatchingChannelEntity.ToInt32() {
return []fab.Orderer{}, nil
}
return nil, errors.WithMessage(err, "failed to get channel network config")
}

Expand Down
12 changes: 12 additions & 0 deletions pkg/fab/channel/transactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@ func TestOrderersFromChannelCfg(t *testing.T) {
assert.NotEmpty(t, o)
}

// TestOrderersFromChannel - tests scenario where err should not be returned if channel config is not found
//instead, empty orderers list should be returned
func TestOrderersFromChannel(t *testing.T) {
user := mspmocks.NewMockSigningIdentity("test", "test")
ctx := mocks.NewMockContext(user)

o, err := orderersFromChannel(ctx, "invalid-channel-id")
assert.Nil(t, err)
assert.NotNil(t, o)
assert.Zero(t, len(o))
}

// TestOrderersFromChannelCfg uses an orderer that does not exist in the configuration.
func TestOrderersFromChannelCfgBadTLS(t *testing.T) {
user := mspmocks.NewMockSigningIdentity("test", "test")
Expand Down

0 comments on commit dd2868a

Please sign in to comment.