Skip to content

Commit 39861b8

Browse files
committed
Add test for the change in previous commit
1 parent 728e87b commit 39861b8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11632,6 +11632,34 @@ mod tests {
1163211632
}
1163311633
}
1163411634

11635+
#[test]
11636+
fn test_channel_update_cached() {
11637+
let chanmon_cfgs = create_chanmon_cfgs(2);
11638+
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
11639+
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
11640+
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
11641+
11642+
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
11643+
11644+
nodes[0].node.force_close_channel_with_peer(&chan.2, &nodes[1].node.get_our_node_id(), None, true).unwrap();
11645+
check_added_monitors!(nodes[0], 1);
11646+
check_closed_event!(nodes[0], 1, ClosureReason::HolderForceClosed, [nodes[1].node.get_our_node_id()], 100000);
11647+
11648+
{
11649+
// Assert that channelUpdate message has been added to node[2] pending msg events
11650+
let pending_broadcast_messages= nodes[0].node.pending_broadcast_messages.lock().unwrap();
11651+
assert_eq!(pending_broadcast_messages.len(), 1);
11652+
}
11653+
11654+
// Confirm that the channel_update was not sent immediately to node[1] but was cached.
11655+
let node_1_events = nodes[1].node.get_and_clear_pending_msg_events();
11656+
assert_eq!(node_1_events.len(), 0);
11657+
11658+
// Confirm that get_and_clear_pending_msg_events correctly captures pending_broadcast_messages
11659+
let node_0_events = nodes[0].node.get_and_clear_pending_msg_events();
11660+
assert_eq!(node_0_events.len(), 1);
11661+
}
11662+
1163511663
#[test]
1163611664
fn test_drop_disconnected_peers_when_removing_channels() {
1163711665
let chanmon_cfgs = create_chanmon_cfgs(2);

0 commit comments

Comments
 (0)