@@ -91,21 +91,51 @@ func TestService(t *testing.T) {
91
91
assert .Contains (t , err .Error (), "failed parsing request" )
92
92
}
93
93
94
- // Scenario V: Request with a CC query where one chaincode is unavailable
94
+ // Scenario V: Request a CC query with no chaincodes at all
95
95
req .Queries [0 ].Query = & discovery.Query_CcQuery {
96
96
CcQuery : & discovery.ChaincodeQuery {
97
- Chaincodes : []string {"unknownCC" , "cc1" },
97
+ Interests : []* discovery.ChaincodeInterest {
98
+ {},
99
+ },
100
+ },
101
+ }
102
+ resp , err = service .Discover (ctx , toSignedRequest (req ))
103
+ assert .NoError (t , err )
104
+ assert .Contains (t , resp .Results [0 ].GetError ().Content , "must include at least one chaincode" )
105
+
106
+ // Scenario VI: Request with a CC query where one chaincode is unavailable
107
+ req .Queries [0 ].Query = & discovery.Query_CcQuery {
108
+ CcQuery : & discovery.ChaincodeQuery {
109
+ Interests : []* discovery.ChaincodeInterest {
110
+ {
111
+ ChaincodeNames : []string {"unknownCC" },
112
+ },
113
+ {
114
+ ChaincodeNames : []string {"cc1" },
115
+ },
116
+ },
98
117
},
99
118
}
100
119
101
120
resp , err = service .Discover (ctx , toSignedRequest (req ))
102
121
assert .NoError (t , err )
103
- assert .Contains (t , resp .Results [0 ].GetError ().Content , "failed constructing descriptor for chaincode unknownCC" )
122
+ assert .Contains (t , resp .Results [0 ].GetError ().Content , "failed constructing descriptor" )
123
+ assert .Contains (t , resp .Results [0 ].GetError ().Content , "unknownCC" )
104
124
105
- // Scenario VI : Request with a CC query where all are available
125
+ // Scenario VII : Request with a CC query where all are available
106
126
req .Queries [0 ].Query = & discovery.Query_CcQuery {
107
127
CcQuery : & discovery.ChaincodeQuery {
108
- Chaincodes : []string {"cc1" , "cc2" , "cc3" },
128
+ Interests : []* discovery.ChaincodeInterest {
129
+ {
130
+ ChaincodeNames : []string {"cc1" },
131
+ },
132
+ {
133
+ ChaincodeNames : []string {"cc2" },
134
+ },
135
+ {
136
+ ChaincodeNames : []string {"cc3" },
137
+ },
138
+ },
109
139
},
110
140
}
111
141
resp , err = service .Discover (ctx , toSignedRequest (req ))
@@ -115,7 +145,7 @@ func TestService(t *testing.T) {
115
145
})
116
146
assert .Equal (t , expected , resp )
117
147
118
- // Scenario VII : Request with a config query
148
+ // Scenario VIII : Request with a config query
119
149
mockSup .On ("Config" , mock .Anything ).Return (nil , errors .New ("failed fetching config" )).Once ()
120
150
req .Queries [0 ].Query = & discovery.Query_ConfigQuery {
121
151
ConfigQuery : & discovery.ConfigQuery {},
@@ -124,7 +154,7 @@ func TestService(t *testing.T) {
124
154
assert .NoError (t , err )
125
155
assert .Contains (t , resp .Results [0 ].GetError ().Content , "failed fetching config for channel channelWithAccessGranted" )
126
156
127
- // Scenario VII : Request with a config query
157
+ // Scenario IX : Request with a config query
128
158
mockSup .On ("Config" , mock .Anything ).Return (& discovery.ConfigResult {}, nil ).Once ()
129
159
req .Queries [0 ].Query = & discovery.Query_ConfigQuery {
130
160
ConfigQuery : & discovery.ConfigQuery {},
@@ -133,7 +163,7 @@ func TestService(t *testing.T) {
133
163
assert .NoError (t , err )
134
164
assert .NotNil (t , resp .Results [0 ].GetConfigResult ())
135
165
136
- // Scenario VIII : Request with a membership query
166
+ // Scenario X : Request with a membership query
137
167
// Peers in membership view: { p0, p1, p2, p3}
138
168
// Peers in channel view: {p1, p2, p4}
139
169
// So that means that the returned peers for the channel should be the intersection
@@ -232,7 +262,7 @@ func TestService(t *testing.T) {
232
262
assert .NoError (t , err )
233
263
}
234
264
235
- // Scenario IX : The client is eligible for channel queries but not for channel-less
265
+ // Scenario XI : The client is eligible for channel queries but not for channel-less
236
266
// since it's not an admin. It sends a query for a channel-less query but puts a channel in the query.
237
267
// It should fail because channel-less query types cannot have a channel configured in them.
238
268
req .Queries = []* discovery.Query {
0 commit comments