Skip to content

Commit

Permalink
Update the relevant tests to account for the new behavior change
Browse files Browse the repository at this point in the history
  • Loading branch information
shaavan committed Dec 11, 2023
1 parent 576d9f2 commit 9dca9c8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lightning/src/ln/functional_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3692,7 +3692,7 @@ fn test_dup_events_on_peer_disconnect() {
#[test]
fn test_peer_disconnected_before_funding_broadcasted() {
// Test that channels are closed with `ClosureReason::DisconnectedPeer` if the peer disconnects
// before the funding transaction has been broadcasted.
// before the funding transaction has been broadcasted, and doesn't reconnect back within time.
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
Expand Down Expand Up @@ -3721,11 +3721,15 @@ fn test_peer_disconnected_before_funding_broadcasted() {
assert_eq!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().len(), 0);
}

// Ensure that the channel is closed with `ClosureReason::DisconnectedPeer` when the peers are
// disconnected before the funding transaction was broadcasted.
// Ensure that the channel is closed after timeout with `ClosureReason::DisconnectedPeer`
// when the peers are disconnected before the funding transaction was broadcasted.
nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());

// The timer ticks while waiting for peer to connect back
nodes[0].node.timer_tick_occurred();
nodes[0].node.timer_tick_occurred();

check_closed_event!(&nodes[0], 2, ClosureReason::DisconnectedPeer, true
, [nodes[1].node.get_our_node_id()], 1000000);
check_closed_event!(&nodes[1], 1, ClosureReason::DisconnectedPeer, false
Expand Down Expand Up @@ -10526,6 +10530,10 @@ fn test_disconnect_in_funding_batch() {
// The remaining peer in the batch disconnects.
nodes[0].node.peer_disconnected(&nodes[2].node.get_our_node_id());

// After the time expires for allowing peer to connect back
nodes[0].node.timer_tick_occurred();
nodes[0].node.timer_tick_occurred();

// The channels in the batch will close immediately.
let channel_id_1 = OutPoint { txid: tx.txid(), index: 0 }.to_channel_id();
let channel_id_2 = OutPoint { txid: tx.txid(), index: 1 }.to_channel_id();
Expand Down

0 comments on commit 9dca9c8

Please sign in to comment.