From 30a77d863f808a2673349fa06573909c5ca120c0 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Wed, 15 Nov 2023 22:50:24 -0500 Subject: [PATCH] Include non-JSON response from Monero node in error --- coins/monero/src/rpc/mod.rs | 30 ++++++++++----------- tests/coordinator/src/tests/batch.rs | 2 +- tests/full-stack/src/tests/mint_and_burn.rs | 4 +-- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/coins/monero/src/rpc/mod.rs b/coins/monero/src/rpc/mod.rs index df1dfb6f4..eaa8f4f40 100644 --- a/coins/monero/src/rpc/mod.rs +++ b/coins/monero/src/rpc/mod.rs @@ -131,23 +131,21 @@ impl Rpc { route: &str, params: Option, ) -> Result { - serde_json::from_str( - std_shims::str::from_utf8( - &self - .0 - .post( - route, - if let Some(params) = params { - serde_json::to_string(¶ms).unwrap().into_bytes() - } else { - vec![] - }, - ) - .await?, + let res = self + .0 + .post( + route, + if let Some(params) = params { + serde_json::to_string(¶ms).unwrap().into_bytes() + } else { + vec![] + }, ) - .map_err(|_| RpcError::InvalidNode("response wasn't utf-8"))?, - ) - .map_err(|_| RpcError::InvalidNode("response wasn't json")) + .await?; + let res_str = std_shims::str::from_utf8(&res) + .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 diff --git a/tests/coordinator/src/tests/batch.rs b/tests/coordinator/src/tests/batch.rs index c1a802e94..8945716c7 100644 --- a/tests/coordinator/src/tests/batch.rs +++ b/tests/coordinator/src/tests/batch.rs @@ -103,7 +103,7 @@ pub async fn batch( participants.insert(known_signer_i); participants } - _ => panic!("coordinator didn't send back SubstratePreprocesses"), + other => panic!("coordinator didn't send back SubstratePreprocesses: {:?}", other), }; for i in participants.clone() { diff --git a/tests/full-stack/src/tests/mint_and_burn.rs b/tests/full-stack/src/tests/mint_and_burn.rs index fc3c5ee86..2c3615e17 100644 --- a/tests/full-stack/src/tests/mint_and_burn.rs +++ b/tests/full-stack/src/tests/mint_and_burn.rs @@ -552,7 +552,7 @@ async fn mint_and_burn_test() { { 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 i = 0; while i < (15 * 6) { @@ -582,7 +582,7 @@ async fn mint_and_burn_test() { } } if !found { - panic!("couldn't find the expected Bitcoin transaction within 5 minutes"); + panic!("couldn't find the expected Bitcoin transaction within 15 minutes"); } }