Include non-JSON response from Monero node in error

This commit is contained in:
Luke Parker
2023-11-15 22:50:24 -05:00
parent a03a1edbff
commit 30a77d863f
3 changed files with 17 additions and 19 deletions

View File

@@ -131,23 +131,21 @@ impl<R: RpcConnection> Rpc<R> {
route: &str, route: &str,
params: Option<Params>, params: Option<Params>,
) -> Result<Response, RpcError> { ) -> Result<Response, RpcError> {
serde_json::from_str( let res = self
std_shims::str::from_utf8( .0
&self .post(
.0 route,
.post( if let Some(params) = params {
route, serde_json::to_string(&params).unwrap().into_bytes()
if let Some(params) = params { } else {
serde_json::to_string(&params).unwrap().into_bytes() vec![]
} else { },
vec![]
},
)
.await?,
) )
.map_err(|_| RpcError::InvalidNode("response wasn't utf-8"))?, .await?;
) let res_str = std_shims::str::from_utf8(&res)
.map_err(|_| RpcError::InvalidNode("response wasn't json")) .map_err(|_| RpcError::InvalidNode("response wasn't utf-8"))?;
serde_json::from_str(res_str)
.map_err(|_| RpcError::InvalidNode("response wasn't json: {res_str}"))
} }
/// Perform a JSON-RPC call with the specified method with the provided parameters /// Perform a JSON-RPC call with the specified method with the provided parameters

View File

@@ -103,7 +103,7 @@ pub async fn batch(
participants.insert(known_signer_i); participants.insert(known_signer_i);
participants participants
} }
_ => panic!("coordinator didn't send back SubstratePreprocesses"), other => panic!("coordinator didn't send back SubstratePreprocesses: {:?}", other),
}; };
for i in participants.clone() { for i in participants.clone() {

View File

@@ -552,7 +552,7 @@ async fn mint_and_burn_test() {
{ {
let rpc = handles[0].bitcoin(&ops).await; let rpc = handles[0].bitcoin(&ops).await;
// Check for up to 5 minutes // Check for up to 15 minutes
let mut found = false; let mut found = false;
let mut i = 0; let mut i = 0;
while i < (15 * 6) { while i < (15 * 6) {
@@ -582,7 +582,7 @@ async fn mint_and_burn_test() {
} }
} }
if !found { if !found {
panic!("couldn't find the expected Bitcoin transaction within 5 minutes"); panic!("couldn't find the expected Bitcoin transaction within 15 minutes");
} }
} }