@@ -203,6 +203,12 @@ pub use crate::ln::outbound_payment::{
203203};
204204use crate::ln::script::ShutdownScript;
205205
206+ /// Test-only hook: if set to a node's pubkey, that node will drop outgoing
207+ /// `funding_signed` messages (sending an `ErrorMessage` instead) in its
208+ /// `internal_funding_created` handler.
209+ #[cfg(any(test, feature = "_rln_test_hooks"))]
210+ pub static DROP_FUNDING_SIGNED_ON_NODE: Mutex<Option<PublicKey>> = Mutex::new(None);
211+
206212// We hold various information about HTLC relay in the HTLC objects in Channel itself:
207213//
208214// Upon receipt of an HTLC from a peer, we'll give it a PendingHTLCStatus indicating if it should
@@ -10510,10 +10516,34 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1051010516 // accepted payment from yet. We do, however, need to wait to send our channel_ready
1051110517 // until we have persisted our monitor.
1051210518 if let Some(msg) = funding_msg_opt {
10513- peer_state.pending_msg_events.push(MessageSendEvent::SendFundingSigned {
10514- node_id: *counterparty_node_id,
10515- msg,
10516- });
10519+ #[cfg(any(test, feature = "_rln_test_hooks"))]
10520+ let drop_funding_signed = DROP_FUNDING_SIGNED_ON_NODE
10521+ .lock()
10522+ .unwrap()
10523+ .as_ref()
10524+ .map_or(false, |id| *id == self.get_our_node_id());
10525+ #[cfg(not(any(test, feature = "_rln_test_hooks")))]
10526+ let drop_funding_signed = false;
10527+ if drop_funding_signed {
10528+ log_error!(
10529+ WithChannelContext::from(&self.logger, &chan.context, None),
10530+ "TEST: dropping funding_signed for channel {funded_channel_id}, sending error instead"
10531+ );
10532+ peer_state.pending_msg_events.push(MessageSendEvent::HandleError {
10533+ node_id: *counterparty_node_id,
10534+ action: msgs::ErrorAction::SendErrorMessage {
10535+ msg: msgs::ErrorMessage {
10536+ channel_id: msg.channel_id,
10537+ data: "TEST: funding_signed dropped".to_owned(),
10538+ },
10539+ },
10540+ });
10541+ } else {
10542+ peer_state.pending_msg_events.push(MessageSendEvent::SendFundingSigned {
10543+ node_id: *counterparty_node_id,
10544+ msg,
10545+ });
10546+ }
1051710547 }
1051810548
1051910549 if let Some(funded_chan) = e.insert(Channel::from(chan)).as_funded_mut() {
0 commit comments