Skip to content

Commit

Permalink
last fixes
Browse files Browse the repository at this point in the history
fix clippy wornings and rust tests that do not pass in json vendored
  • Loading branch information
lorbax committed Oct 12, 2023
1 parent 8aed444 commit a16708e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions roles/jd-server/src/lib/mempool/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ impl RpcApi for RpcClient {
let raw_args: Vec<_> = args
.iter()
.map(|a| {
let json_string = serde_json::to_string(a)?;
serde_json::value::RawValue::from_string(json_string) // we can't use to_raw_value here due to compat with Rust 1.29
let json_string = serde_json::to_string(a).map_err(BitcoincoreRpcError::Json)?;
serde_json::value::RawValue::from_string(json_string)
.map_err(BitcoincoreRpcError::Json) // we can't use to_raw_value here due to compat with Rust 1.29
})
.map(|a| a.map_err(|e| BitcoincoreRpcError::Json(e)))
.collect::<RResult<Vec<_>>>()?;
let req = self.client.build_request(cmd, &raw_args);
//if log_enabled!(Debug) {
Expand Down
10 changes: 6 additions & 4 deletions vendored/rust-jsonrpc/src/simple_tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ impl TcpTransport {
let mut message_writer = BufWriter::new(sock.try_clone().unwrap());
let message_w = serde_json::to_string(&req).unwrap();
let message_w = message_w.into_bytes();
let _n = message_writer.write(&message_w)?;
message_writer.write_all(&message_w)?;
message_writer.flush()?;
//serde_json::to_writer(&mut sock, &req)?;

// NOTE: we don't check the id there, so it *must* be synchronous
// memo reader and writer are changed because the serde import is custom, therefore we do
// bnot have serde::json::to_writer or serde_json::from_reader

let mut message_reader = BufReader::new(sock).lines();
let message_w = message_reader.next().unwrap().unwrap();
let mut message_reader = BufReader::new(sock);
let mut message_w = String::new();
let _ = message_reader.read_line(&mut message_w);

let resp: R = serde_json::Deserializer::from_str(&message_w)
.into_iter()
Expand Down Expand Up @@ -179,7 +181,7 @@ mod tests {

stream.write_all(&dummy_resp_ser).unwrap();
stream.flush().unwrap();
let recv_resp = client_thread.join().unwrap();
let recv_resp = client_thread.join().unwrap(); //line 184
assert_eq!(serde_json::to_vec(&recv_resp).unwrap(), dummy_resp_ser);
}
}

0 comments on commit a16708e

Please sign in to comment.