Skip to content

Commit

Permalink
Include non-JSON response from Monero node in error
Browse files Browse the repository at this point in the history
  • Loading branch information
kayabaNerve committed Nov 16, 2023
1 parent a03a1ed commit 30a77d8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
30 changes: 14 additions & 16 deletions coins/monero/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,21 @@ impl<R: RpcConnection> Rpc<R> {
route: &str,
params: Option<Params>,
) -> Result<Response, RpcError> {
serde_json::from_str(
std_shims::str::from_utf8(
&self
.0
.post(
route,
if let Some(params) = params {
serde_json::to_string(&params).unwrap().into_bytes()
} else {
vec![]
},
)
.await?,
let res = self
.0
.post(
route,
if let Some(params) = params {
serde_json::to_string(&params).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
Expand Down
2 changes: 1 addition & 1 deletion tests/coordinator/src/tests/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions tests/full-stack/src/tests/mint_and_burn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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");
}
}

Expand Down

0 comments on commit 30a77d8

Please sign in to comment.