We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7cef9c5 commit 42c02a2Copy full SHA for 42c02a2
lightning-block-sync/src/rpc.rs
@@ -140,6 +140,21 @@ mod tests {
140
}
141
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
158
#[tokio::test]
159
async fn call_method_returning_valid_result() {
160
let response = serde_json::json!({ "result": 654470 });
0 commit comments