@@ -9889,51 +9889,53 @@ fn test_payment_with_custom_min_cltv_expiry_delta() {
9889
9889
do_payment_with_custom_min_final_cltv_expiry(true, true);
9890
9890
}
9891
9891
9892
- #[test]
9893
- fn test_disconnects_peer_awaiting_response_ticks() {
9894
- // Tests that nodes which are awaiting on a response critical for channel responsiveness
9895
- // disconnect their counterparty after `DISCONNECT_PEER_AWAITING_RESPONSE_TICKS`.
9896
- let mut chanmon_cfgs = create_chanmon_cfgs(2);
9897
- let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
9898
- let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
9899
- let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
9900
-
9901
- // Asserts a disconnect event is queued to the user.
9902
- let check_disconnect_event = |node: &Node, should_disconnect: bool| {
9903
- let disconnect_event = node.node.get_and_clear_pending_msg_events().iter().find_map(|event|
9904
- if let MessageSendEvent::HandleError { action, .. } = event {
9905
- if let msgs::ErrorAction::DisconnectPeerWithWarning { .. } = action {
9906
- Some(())
9907
- } else {
9908
- None
9909
- }
9892
+ // Disconnect awaiting response helpers
9893
+
9894
+ // Asserts a disconnect event is queued to the user.
9895
+ fn check_disconnect_event(node: &Node, should_disconnect: bool) {
9896
+ let disconnect_event = node.node.get_and_clear_pending_msg_events().iter().find_map(|event|
9897
+ if let MessageSendEvent::HandleError { action, .. } = event {
9898
+ if let msgs::ErrorAction::DisconnectPeerWithWarning { .. } = action {
9899
+ Some(())
9910
9900
} else {
9911
9901
None
9912
9902
}
9913
- );
9914
- assert_eq!(disconnect_event.is_some(), should_disconnect);
9915
- };
9903
+ } else {
9904
+ None
9905
+ }
9906
+ );
9907
+ assert_eq!(disconnect_event.is_some(), should_disconnect);
9908
+ }
9916
9909
9917
- // Fires timer ticks ensuring we only attempt to disconnect peers after reaching
9918
- // `DISCONNECT_PEER_AWAITING_RESPONSE_TICKS`.
9919
- let check_disconnect = |node: &Node| {
9920
- // No disconnect without any timer ticks.
9910
+ // Fires timer ticks ensuring we only attempt to disconnect peers after reaching
9911
+ // `DISCONNECT_PEER_AWAITING_RESPONSE_TICKS`.
9912
+ fn check_disconnect(node: &Node) {
9913
+ // No disconnect without any timer ticks.
9914
+ check_disconnect_event(node, false);
9915
+
9916
+ // No disconnect with 1 timer tick less than required.
9917
+ for _ in 0..DISCONNECT_PEER_AWAITING_RESPONSE_TICKS - 1 {
9918
+ node.node.timer_tick_occurred();
9921
9919
check_disconnect_event(node, false);
9920
+ }
9922
9921
9923
- // No disconnect with 1 timer tick less than required.
9924
- for _ in 0..DISCONNECT_PEER_AWAITING_RESPONSE_TICKS - 1 {
9925
- node.node.timer_tick_occurred();
9926
- check_disconnect_event(node, false);
9927
- }
9922
+ // Disconnect after reaching the required ticks.
9923
+ node.node.timer_tick_occurred();
9924
+ check_disconnect_event(node, true);
9928
9925
9929
- // Disconnect after reaching the required ticks.
9930
- node.node.timer_tick_occurred();
9931
- check_disconnect_event(node, true);
9926
+ // Disconnect again on the next tick if the peer hasn't been disconnected yet.
9927
+ node.node.timer_tick_occurred();
9928
+ check_disconnect_event(node, true);
9929
+ }
9932
9930
9933
- // Disconnect again on the next tick if the peer hasn't been disconnected yet.
9934
- node.node.timer_tick_occurred();
9935
- check_disconnect_event(node, true);
9936
- };
9931
+ #[test]
9932
+ fn test_disconnects_peer_awaiting_response_ticks() {
9933
+ // Tests that nodes which are awaiting on a response critical for channel responsiveness
9934
+ // disconnect their counterparty after `DISCONNECT_PEER_AWAITING_RESPONSE_TICKS`.
9935
+ let mut chanmon_cfgs = create_chanmon_cfgs(2);
9936
+ let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
9937
+ let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
9938
+ let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
9937
9939
9938
9940
create_chan_between_nodes(&nodes[0], &nodes[1]);
9939
9941
@@ -10016,11 +10018,11 @@ fn test_disconnects_peer_awaiting_response_ticks() {
10016
10018
check_disconnect_event(node, false);
10017
10019
}
10018
10020
}
10021
+ }
10019
10022
10020
- // V1 Channel Establishment
10023
+ #[test]
10024
+ fn disconnect_peer_on_v1_channel_establish_not_progressing() {
10021
10025
// Disconnects on pending channel timeout
10022
-
10023
- // Set up some fresh nodes.
10024
10026
let mut chanmon_cfgs = create_chanmon_cfgs(2);
10025
10027
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
10026
10028
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
0 commit comments