Skip to content

Commit 7e9480b

Browse files
committed
f send when we should
1 parent 9a23257 commit 7e9480b

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,14 @@ impl MsgHandleErrInternal {
613613
Self {
614614
err: match err {
615615
ChannelError::Warn(msg) => LightningError {
616-
err: msg,
617-
action: msgs::ErrorAction::IgnoreError,
616+
err: msg.clone(),
617+
action: msgs::ErrorAction::SendWarningMessage {
618+
msg: msgs::WarningMessage {
619+
channel_id,
620+
data: msg
621+
},
622+
log_level: Level::Warn,
623+
},
618624
},
619625
ChannelError::Ignore(msg) => LightningError {
620626
err: msg,
@@ -1373,9 +1379,7 @@ macro_rules! convert_chan_err {
13731379
($self: ident, $err: expr, $short_to_id: expr, $channel: expr, $channel_id: expr) => {
13741380
match $err {
13751381
ChannelError::Warn(msg) => {
1376-
//TODO: Once warning messages are merged, we should send a `warning` message to our
1377-
//peer here.
1378-
(false, MsgHandleErrInternal::from_chan_no_close(ChannelError::Ignore(msg), $channel_id.clone()))
1382+
(false, MsgHandleErrInternal::from_chan_no_close(ChannelError::Warn(msg), $channel_id.clone()))
13791383
},
13801384
ChannelError::Ignore(msg) => {
13811385
(false, MsgHandleErrInternal::from_chan_no_close(ChannelError::Ignore(msg), $channel_id.clone()))

lightning/src/ln/functional_test_utils.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,22 @@ macro_rules! get_closing_signed_broadcast {
780780
}
781781
}
782782

783+
#[cfg(test)]
784+
macro_rules! check_warn_msg {
785+
($node: expr, $recipient_node_id: expr, $chan_id: expr) => {{
786+
let msg_events = $node.node.get_and_clear_pending_msg_events();
787+
assert_eq!(msg_events.len(), 1);
788+
match msg_events[0] {
789+
MessageSendEvent::HandleError { action: ErrorAction::SendWarningMessage { ref msg, log_level: _ }, node_id } => {
790+
assert_eq!(node_id, $recipient_node_id);
791+
assert_eq!(msg.channel_id, $chan_id);
792+
msg.data.clone()
793+
},
794+
_ => panic!("Unexpected event"),
795+
}
796+
}}
797+
}
798+
783799
/// Check that a channel's closing channel update has been broadcasted, and optionally
784800
/// check whether an error message event has occurred.
785801
#[macro_export]

lightning/src/ln/shutdown_tests.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -762,10 +762,8 @@ fn do_test_closing_signed_reinit_timeout(timeout_step: TimeoutStep) {
762762

763763
if timeout_step != TimeoutStep::AfterShutdown {
764764
nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_closing_signed);
765-
// At this point nodes[1] should send back a warning message indicating it disagrees with the
766-
// given channel-closing fee. Currently we do not implement warning messages so instead we
767-
// remain silent here.
768-
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
765+
assert!(check_warn_msg!(nodes[1], nodes[0].node.get_our_node_id(), chan_id)
766+
.starts_with("Unable to come to consensus about closing feerate"));
769767

770768
// Now deliver a mutated closing_signed indicating a higher acceptable fee range, which
771769
// nodes[1] should happily accept and respond to.

0 commit comments

Comments
 (0)