@@ -199,68 +199,68 @@ func TestNewPeer(t *testing.T) {
199
199
200
200
func TestMatchProtocols (t * testing.T ) {
201
201
tests := []struct {
202
- Local []Cap
203
- Remote []Protocol
202
+ Remote []Cap
203
+ Local []Protocol
204
204
Match map [string ]protoRW
205
205
}{
206
206
{
207
- // No remote protocols
208
- Local : []Cap {{Name : "a" }},
207
+ // No remote capabilities
208
+ Local : []Protocol {{Name : "a" }},
209
209
},
210
210
{
211
- // No local capabilities
212
- Remote : []Protocol {{Name : "a" }},
211
+ // No local protocols
212
+ Remote : []Cap {{Name : "a" }},
213
213
},
214
214
{
215
215
// No mutual protocols
216
- Local : []Cap {{Name : "a" }},
217
- Remote : []Protocol {{Name : "b" }},
216
+ Remote : []Cap {{Name : "a" }},
217
+ Local : []Protocol {{Name : "b" }},
218
218
},
219
219
{
220
220
// Some matches, some differences
221
- Local : []Cap {{Name : "local" }, {Name : "match1" }, {Name : "match2" }},
222
- Remote : []Protocol {{Name : "match1" }, {Name : "match2" }, {Name : "remote" }},
221
+ Remote : []Cap {{Name : "local" }, {Name : "match1" }, {Name : "match2" }},
222
+ Local : []Protocol {{Name : "match1" }, {Name : "match2" }, {Name : "remote" }},
223
223
Match : map [string ]protoRW {"match1" : {Protocol : Protocol {Name : "match1" }}, "match2" : {Protocol : Protocol {Name : "match2" }}},
224
224
},
225
225
{
226
226
// Various alphabetical ordering
227
- Local : []Cap {{Name : "aa" }, {Name : "ab" }, {Name : "bb" }, {Name : "ba" }},
228
- Remote : []Protocol {{Name : "ba" }, {Name : "bb" }, {Name : "ab" }, {Name : "aa" }},
227
+ Remote : []Cap {{Name : "aa" }, {Name : "ab" }, {Name : "bb" }, {Name : "ba" }},
228
+ Local : []Protocol {{Name : "ba" }, {Name : "bb" }, {Name : "ab" }, {Name : "aa" }},
229
229
Match : map [string ]protoRW {"aa" : {Protocol : Protocol {Name : "aa" }}, "ab" : {Protocol : Protocol {Name : "ab" }}, "ba" : {Protocol : Protocol {Name : "ba" }}, "bb" : {Protocol : Protocol {Name : "bb" }}},
230
230
},
231
231
{
232
232
// No mutual versions
233
- Local : []Cap {{Version : 1 }},
234
- Remote : []Protocol {{Version : 2 }},
233
+ Remote : []Cap {{Version : 1 }},
234
+ Local : []Protocol {{Version : 2 }},
235
235
},
236
236
{
237
237
// Multiple versions, single common
238
- Local : []Cap {{Version : 1 }, {Version : 2 }},
239
- Remote : []Protocol {{Version : 2 }, {Version : 3 }},
238
+ Remote : []Cap {{Version : 1 }, {Version : 2 }},
239
+ Local : []Protocol {{Version : 2 }, {Version : 3 }},
240
240
Match : map [string ]protoRW {"" : {Protocol : Protocol {Version : 2 }}},
241
241
},
242
242
{
243
243
// Multiple versions, multiple common
244
- Local : []Cap {{Version : 1 }, {Version : 2 }, {Version : 3 }, {Version : 4 }},
245
- Remote : []Protocol {{Version : 2 }, {Version : 3 }},
244
+ Remote : []Cap {{Version : 1 }, {Version : 2 }, {Version : 3 }, {Version : 4 }},
245
+ Local : []Protocol {{Version : 2 }, {Version : 3 }},
246
246
Match : map [string ]protoRW {"" : {Protocol : Protocol {Version : 3 }}},
247
247
},
248
248
{
249
249
// Various version orderings
250
- Local : []Cap {{Version : 4 }, {Version : 1 }, {Version : 3 }, {Version : 2 }},
251
- Remote : []Protocol {{Version : 2 }, {Version : 3 }, {Version : 1 }},
250
+ Remote : []Cap {{Version : 4 }, {Version : 1 }, {Version : 3 }, {Version : 2 }},
251
+ Local : []Protocol {{Version : 2 }, {Version : 3 }, {Version : 1 }},
252
252
Match : map [string ]protoRW {"" : {Protocol : Protocol {Version : 3 }}},
253
253
},
254
254
{
255
255
// Versions overriding sub-protocol lengths
256
- Local : []Cap {{Version : 1 }, {Version : 2 }, {Version : 3 }, {Name : "a" }},
257
- Remote : []Protocol {{Version : 1 , Length : 1 }, {Version : 2 , Length : 2 }, {Version : 3 , Length : 3 }, {Name : "a" }},
256
+ Remote : []Cap {{Version : 1 }, {Version : 2 }, {Version : 3 }, {Name : "a" }},
257
+ Local : []Protocol {{Version : 1 , Length : 1 }, {Version : 2 , Length : 2 }, {Version : 3 , Length : 3 }, {Name : "a" }},
258
258
Match : map [string ]protoRW {"" : {Protocol : Protocol {Version : 3 }}, "a" : {Protocol : Protocol {Name : "a" }, offset : 3 }},
259
259
},
260
260
}
261
261
262
262
for i , tt := range tests {
263
- result := matchProtocols (tt .Remote , tt .Local , nil )
263
+ result := matchProtocols (tt .Local , tt .Remote , nil )
264
264
if len (result ) != len (tt .Match ) {
265
265
t .Errorf ("test %d: negotiation mismatch: have %v, want %v" , i , len (result ), len (tt .Match ))
266
266
continue
0 commit comments