File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,21 @@ mod tests {
140
140
}
141
141
}
142
142
143
+ #[ tokio:: test]
144
+ async fn call_method_returning_malformed_result ( ) {
145
+ let response = serde_json:: json!( { "result" : "foo" } ) ;
146
+ let server = HttpServer :: responding_with_ok ( MessageBody :: Content ( response) ) ;
147
+ let mut client = RpcClient :: new ( CREDENTIALS , server. endpoint ( ) ) . unwrap ( ) ;
148
+
149
+ match client. call_method :: < u64 > ( "getblockcount" , & [ ] ) . await {
150
+ Err ( e) => {
151
+ assert_eq ! ( e. kind( ) , std:: io:: ErrorKind :: InvalidData ) ;
152
+ assert_eq ! ( e. get_ref( ) . unwrap( ) . to_string( ) , "not a number" ) ;
153
+ } ,
154
+ Ok ( _) => panic ! ( "Expected error" ) ,
155
+ }
156
+ }
157
+
143
158
#[ tokio:: test]
144
159
async fn call_method_returning_valid_result ( ) {
145
160
let response = serde_json:: json!( { "result" : 654470 } ) ;
You can’t perform that action at this time.
0 commit comments