Skip to content

Commit ecbe6a0

Browse files
committed
f send when we should
1 parent 1d5db19 commit ecbe6a0

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
@@ -298,8 +298,14 @@ impl MsgHandleErrInternal {
298298
Self {
299299
err: match err {
300300
ChannelError::Warn(msg) => LightningError {
301-
err: msg,
302-
action: msgs::ErrorAction::IgnoreError,
301+
err: msg.clone(),
302+
action: msgs::ErrorAction::SendWarningMessage {
303+
msg: msgs::WarningMessage {
304+
channel_id,
305+
data: msg
306+
},
307+
log_level: Level::Warn,
308+
},
303309
},
304310
ChannelError::Ignore(msg) => LightningError {
305311
err: msg,
@@ -866,9 +872,7 @@ macro_rules! convert_chan_err {
866872
($self: ident, $err: expr, $short_to_id: expr, $channel: expr, $channel_id: expr) => {
867873
match $err {
868874
ChannelError::Warn(msg) => {
869-
//TODO: Once warning messages are merged, we should send a `warning` message to our
870-
//peer here.
871-
(false, MsgHandleErrInternal::from_chan_no_close(ChannelError::Ignore(msg), $channel_id.clone()))
875+
(false, MsgHandleErrInternal::from_chan_no_close(ChannelError::Warn(msg), $channel_id.clone()))
872876
},
873877
ChannelError::Ignore(msg) => {
874878
(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
@@ -738,6 +738,22 @@ macro_rules! get_closing_signed_broadcast {
738738
}
739739
}
740740

741+
#[cfg(test)]
742+
macro_rules! check_warn_msg {
743+
($node: expr, $recipient_node_id: expr, $chan_id: expr) => {{
744+
let msg_events = $node.node.get_and_clear_pending_msg_events();
745+
assert_eq!(msg_events.len(), 1);
746+
match msg_events[0] {
747+
MessageSendEvent::HandleError { action: ErrorAction::SendWarningMessage { ref msg, log_level: _ }, node_id } => {
748+
assert_eq!(node_id, $recipient_node_id);
749+
assert_eq!(msg.channel_id, $chan_id);
750+
msg.data.clone()
751+
},
752+
_ => panic!("Unexpected event"),
753+
}
754+
}}
755+
}
756+
741757
/// Check that a channel's closing channel update has been broadcasted, and optionally
742758
/// check whether an error message event has occurred.
743759
#[macro_export]

lightning/src/ln/shutdown_tests.rs

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

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

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

0 commit comments

Comments
 (0)