@@ -181,6 +181,18 @@ func TestHandle(t *testing.T) {
181
181
return 0 , nil
182
182
},
183
183
},
184
+ {
185
+ Name : "multipleOptionalParams" ,
186
+ Params : []jsonrpc.Parameter {
187
+ {Name : "param1" },
188
+ {Name : "param2" },
189
+ {Name : "param3" , Optional : true },
190
+ {Name : "param4" , Optional : true },
191
+ },
192
+ Handler : func (param1 * int , param2 []int , param3 * int , param4 []int ) (int , * jsonrpc.Error ) {
193
+ return 0 , nil
194
+ },
195
+ },
184
196
}
185
197
186
198
listener := CountingEventListener {}
@@ -218,10 +230,6 @@ func TestHandle(t *testing.T) {
218
230
req : `{"jsonrpc" : "2.0", "method" : "method", "id" : 5}` ,
219
231
res : `{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid Params","data":"missing non-optional param field"},"id":5}` ,
220
232
},
221
- "missing param(s)" : {
222
- req : `{"jsonrpc" : "2.0", "method" : "method", "params" : [3, false] , "id" : 3}` ,
223
- res : `{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid Params","data":"missing/unexpected params in list"},"id":3}` ,
224
- },
225
233
"too many params" : {
226
234
req : `{"jsonrpc" : "2.0", "method" : "method", "params" : [3, false, "error message", "too many"] , "id" : 3}` ,
227
235
res : `{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid Params","data":"missing/unexpected params in list"},"id":3}` ,
@@ -490,6 +498,14 @@ func TestHandle(t *testing.T) {
490
498
req : `{"jsonrpc": "2.0", "method": "singleOptionalParam", "id": 1}` ,
491
499
res : `{"jsonrpc":"2.0","result":0,"id":1}` ,
492
500
},
501
+ "empty multiple optional params" : {
502
+ req : `{"jsonrpc": "2.0", "method": "multipleOptionalParams", "params": {"param1": 1, "param2": [2, 3]}, "id": 1}` ,
503
+ res : `{"jsonrpc":"2.0","result":0,"id":1}` ,
504
+ },
505
+ "empty multiple optional positional params" : {
506
+ req : `{"jsonrpc": "2.0", "method": "multipleOptionalParams", "params": [1, [2, 3]], "id": 1}` ,
507
+ res : `{"jsonrpc":"2.0","result":0,"id":1}` ,
508
+ },
493
509
}
494
510
495
511
for desc , test := range tests {
0 commit comments