Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit dd2868a

Browse files
committed
[FAB-9983] fixing endpointconfig channels
-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>
1 parent 5ac2d97 commit dd2868a

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

pkg/fab/channel/transactor.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ func orderersFromChannel(ctx context.Client, channelID string) ([]fab.Orderer, e
117117

118118
chNetworkConfig, err := ctx.EndpointConfig().ChannelConfig(channelID)
119119
if err != nil {
120+
s, ok := status.FromError(err)
121+
if ok && s.Code == status.NoMatchingChannelEntity.ToInt32() {
122+
return []fab.Orderer{}, nil
123+
}
120124
return nil, errors.WithMessage(err, "failed to get channel network config")
121125
}
122126

pkg/fab/channel/transactor_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,18 @@ func TestOrderersFromChannelCfg(t *testing.T) {
130130
assert.NotEmpty(t, o)
131131
}
132132

133+
// TestOrderersFromChannel - tests scenario where err should not be returned if channel config is not found
134+
//instead, empty orderers list should be returned
135+
func TestOrderersFromChannel(t *testing.T) {
136+
user := mspmocks.NewMockSigningIdentity("test", "test")
137+
ctx := mocks.NewMockContext(user)
138+
139+
o, err := orderersFromChannel(ctx, "invalid-channel-id")
140+
assert.Nil(t, err)
141+
assert.NotNil(t, o)
142+
assert.Zero(t, len(o))
143+
}
144+
133145
// TestOrderersFromChannelCfg uses an orderer that does not exist in the configuration.
134146
func TestOrderersFromChannelCfgBadTLS(t *testing.T) {
135147
user := mspmocks.NewMockSigningIdentity("test", "test")

0 commit comments

Comments
 (0)