mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-03-03 18:47:47 +01:00
Use ChannelUnavailable
for a peer disconnecting not MisuseError
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.
This commit is contained in:
parent
fb5b427cba
commit
f9bafa6d0e
2 changed files with 4 additions and 2 deletions
|
@ -632,7 +632,9 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
|
||||||
// It's possible the channel has been closed in the mean time, but any other
|
// It's possible the channel has been closed in the mean time, but any other
|
||||||
// failure may be a bug.
|
// failure may be a bug.
|
||||||
if let APIError::ChannelUnavailable { err } = e {
|
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!(); }
|
} else { panic!(); }
|
||||||
}
|
}
|
||||||
pending_funding_signatures.insert(funding_output, tx);
|
pending_funding_signatures.insert(funding_output, tx);
|
||||||
|
|
|
@ -2552,7 +2552,7 @@ where
|
||||||
let per_peer_state = self.per_peer_state.read().unwrap();
|
let per_peer_state = self.per_peer_state.read().unwrap();
|
||||||
let peer_state_mutex_opt = per_peer_state.get(counterparty_node_id);
|
let peer_state_mutex_opt = per_peer_state.get(counterparty_node_id);
|
||||||
if let None = peer_state_mutex_opt {
|
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();
|
let mut peer_state_lock = peer_state_mutex_opt.unwrap().lock().unwrap();
|
||||||
|
|
Loading…
Add table
Reference in a new issue