@@ -3692,7 +3692,7 @@ fn test_dup_events_on_peer_disconnect() {
3692
3692
#[test]
3693
3693
fn test_peer_disconnected_before_funding_broadcasted() {
3694
3694
// Test that channels are closed with `ClosureReason::DisconnectedPeer` if the peer disconnects
3695
- // before the funding transaction has been broadcasted.
3695
+ // before the funding transaction has been broadcasted, and doesn't reconnect back within time .
3696
3696
let chanmon_cfgs = create_chanmon_cfgs(2);
3697
3697
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
3698
3698
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
@@ -3721,11 +3721,15 @@ fn test_peer_disconnected_before_funding_broadcasted() {
3721
3721
assert_eq!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().len(), 0);
3722
3722
}
3723
3723
3724
- // Ensure that the channel is closed with `ClosureReason::DisconnectedPeer` when the peers are
3725
- // disconnected before the funding transaction was broadcasted.
3724
+ // Ensure that the channel is closed after timeout with `ClosureReason::DisconnectedPeer`
3725
+ // when the peers are disconnected before the funding transaction was broadcasted.
3726
3726
nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
3727
3727
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
3728
3728
3729
+ // The timer ticks while waiting for peer to connect back
3730
+ nodes[0].node.timer_tick_occurred();
3731
+ nodes[0].node.timer_tick_occurred();
3732
+
3729
3733
check_closed_event!(&nodes[0], 2, ClosureReason::DisconnectedPeer, true
3730
3734
, [nodes[1].node.get_our_node_id()], 1000000);
3731
3735
check_closed_event!(&nodes[1], 1, ClosureReason::DisconnectedPeer, false
@@ -10526,6 +10530,10 @@ fn test_disconnect_in_funding_batch() {
10526
10530
// The remaining peer in the batch disconnects.
10527
10531
nodes[0].node.peer_disconnected(&nodes[2].node.get_our_node_id());
10528
10532
10533
+ // After the time expires for allowing peer to connect back
10534
+ nodes[0].node.timer_tick_occurred();
10535
+ nodes[0].node.timer_tick_occurred();
10536
+
10529
10537
// The channels in the batch will close immediately.
10530
10538
let channel_id_1 = OutPoint { txid: tx.txid(), index: 0 }.to_channel_id();
10531
10539
let channel_id_2 = OutPoint { txid: tx.txid(), index: 1 }.to_channel_id();
0 commit comments