This fixes a crash in the `full_stack_target` fuzz test (found by
Chaincode's generous fuzzing infrastructure!) but ultimately is a
better error code - a peer disconnecting before we can fund a
channel isn't a "misuse error" its an unavailable channel.
// It's possible the channel has been closed in the mean time, but any other
// failure may be a bug.
if let APIError::ChannelUnavailable { err } = e {
- assert_eq!(err, "No such channel");
+ if !err.starts_with("Can't find a peer matching the passed counterparty node_id ") {
+ assert_eq!(err, "No such channel");
+ }
} else { panic!(); }
}
pending_funding_signatures.insert(funding_output, tx);
let per_peer_state = self.per_peer_state.read().unwrap();
let peer_state_mutex_opt = per_peer_state.get(counterparty_node_id);
if let None = peer_state_mutex_opt {
- return Err(APIError::APIMisuseError { err: format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id) })
+ return Err(APIError::ChannelUnavailable { err: format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id) })
}
let mut peer_state_lock = peer_state_mutex_opt.unwrap().lock().unwrap();