Skip to content

Commit d5b37bd

Browse files
committed
f split test out
1 parent 9437851 commit d5b37bd

File tree

1 file changed

+42
-40
lines changed

1 file changed

+42
-40
lines changed

lightning/src/ln/functional_tests.rs

+42-40
Original file line numberDiff line numberDiff line change
@@ -9889,51 +9889,53 @@ fn test_payment_with_custom_min_cltv_expiry_delta() {
98899889
do_payment_with_custom_min_final_cltv_expiry(true, true);
98909890
}
98919891

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(())
99109900
} else {
99119901
None
99129902
}
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+
}
99169909

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();
99219919
check_disconnect_event(node, false);
9920+
}
99229921

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);
99289925

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+
}
99329930

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);
99379939

99389940
create_chan_between_nodes(&nodes[0], &nodes[1]);
99399941

@@ -10016,11 +10018,11 @@ fn test_disconnects_peer_awaiting_response_ticks() {
1001610018
check_disconnect_event(node, false);
1001710019
}
1001810020
}
10021+
}
1001910022

10020-
// V1 Channel Establishment
10023+
#[test]
10024+
fn disconnect_peer_on_v1_channel_establish_not_progressing() {
1002110025
// Disconnects on pending channel timeout
10022-
10023-
// Set up some fresh nodes.
1002410026
let mut chanmon_cfgs = create_chanmon_cfgs(2);
1002510027
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
1002610028
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);

0 commit comments

Comments
 (0)