Skip to content

Commit

Permalink
Add extra test + minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
afilini committed Jul 16, 2020
1 parent 110fff5 commit 335fd49
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/raw_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,11 @@ impl<S: Read + Write> RawClient<S> {
// move on
trace!("Reader thread received response for {}", resp_id);

let mut map = self.waiting_map.lock().unwrap();
if let Some(sender) = map.get(&resp_id) {
if let Some(sender) = self.waiting_map.lock().unwrap().remove(&resp_id)
{
sender
.send(ChannelMessage::Response(resp))
.expect("Unable to send the response");
map.remove(&resp_id);
} else {
warn!("Missing listener for {}", resp_id);
}
Expand Down Expand Up @@ -1098,4 +1097,12 @@ mod test {
// Just make sure that the call returns Ok(something)
client.script_subscribe(&addr.script_pubkey()).unwrap();
}

#[test]
fn test_request_after_error() {
let client = RawClient::new(get_test_server()).unwrap();

assert!(client.transaction_broadcast_raw(&[0x00]).is_err());
assert!(client.server_features().is_ok());
}
}

0 comments on commit 335fd49

Please sign in to comment.