@@ -348,14 +348,18 @@ mod tests {
348348 assert_eq ! ( response_any, data_response) ;
349349 }
350350
351+ type ResponseResult = u32 ;
352+ type ErrorData = String ;
353+ type RequestParams = Vec < u32 > ;
354+
351355 struct Add { }
352356
353357 #[ async_trait]
354- impl THandler < Vec < u32 > , u32 , String > for Add {
358+ impl THandler < RequestParams , ResponseResult , ErrorData > for Add {
355359 async fn handle (
356360 & self ,
357- json_rpc2 : Arc < JsonRpc2 < Vec < u32 > , u32 , String > > ,
358- request : Request < Vec < u32 > > ,
361+ json_rpc2 : Arc < JsonRpc2 < RequestParams , ResponseResult , ErrorData > > ,
362+ request : Request < RequestParams > ,
359363 ) {
360364 match request. method . as_str ( ) {
361365 "add" => {
@@ -399,16 +403,15 @@ mod tests {
399403 . await
400404 . expect ( "cannot generate object stream" ) ;
401405
402- let conn_arc = JsonRpc2 :: < _ , u32 , String > :: new ( Box :: new ( client_stream) , None ) . await ;
406+ let conn_arc =
407+ JsonRpc2 :: < _ , ResponseResult , ErrorData > :: new ( Box :: new ( client_stream) , None ) . await ;
403408
404409 time:: sleep ( time:: Duration :: new ( 2 , 0 ) ) . await ;
405- println ! ( "adfadfadf" ) ;
406410 match conn_arc. call ( "add" , Some ( vec ! [ 2u32 , 3u32 , 4u32 ] ) ) . await {
407411 Ok ( response) => {
408412 let result = response. result . unwrap ( ) ;
409- print ! ( "result: {}" , result ) ;
413+
410414 assert_eq ! ( result, 9 ) ;
411- println ! ( "adfadfadf===" ) ;
412415 }
413416 Err ( err) => {
414417 log:: error!( "call add error: {}" , err) ;
0 commit comments