Skip to content

Commit b4eb92c

Browse files
committed
f add test
1 parent 293556a commit b4eb92c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

lightning-invoice/src/utils.rs

+27
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,33 @@ mod test {
734734
match_invoice_routes(Some(5000), &nodes[0], scid_aliases);
735735
}
736736

737+
#[test]
738+
fn test_hints_has_only_online_channels() {
739+
let chanmon_cfgs = create_chanmon_cfgs(3);
740+
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
741+
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
742+
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
743+
let chan_a = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 0, 10_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
744+
let chan_b = create_unannounced_chan_between_nodes_with_value(&nodes, 2, 0, 10_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
745+
746+
// With both peers connected we should get all hints
747+
let mut scid_aliases = HashSet::new();
748+
scid_aliases.insert(chan_a.0.short_channel_id_alias.unwrap());
749+
scid_aliases.insert(chan_b.0.short_channel_id_alias.unwrap());
750+
751+
match_invoice_routes(Some(5000), &nodes[0], scid_aliases.clone());
752+
753+
// With only one peer connected other hints should go away
754+
scid_aliases.remove(&chan_b.0.short_channel_id_alias.unwrap());
755+
nodes[0].node.peer_disconnected(&nodes[2].node.get_our_node_id(), false);
756+
match_invoice_routes(Some(5000), &nodes[0], scid_aliases.clone());
757+
758+
// With both peers disconnected we should just get all the hints
759+
scid_aliases.insert(chan_b.0.short_channel_id_alias.unwrap());
760+
nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false);
761+
match_invoice_routes(Some(5000), &nodes[0], scid_aliases);
762+
}
763+
737764
#[test]
738765
fn test_forwarding_info_not_assigned_channel_excluded_from_hints() {
739766
let chanmon_cfgs = create_chanmon_cfgs(3);

0 commit comments

Comments
 (0)