+ #[test]
+ fn test_hints_has_only_online_channels() {
+ let chanmon_cfgs = create_chanmon_cfgs(4);
+ let node_cfgs = create_node_cfgs(4, &chanmon_cfgs);
+ let node_chanmgrs = create_node_chanmgrs(4, &node_cfgs, &[None, None, None, None]);
+ let nodes = create_network(4, &node_cfgs, &node_chanmgrs);
+ 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());
+ 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());
+ let _chan_c = create_unannounced_chan_between_nodes_with_value(&nodes, 3, 0, 1_000_000, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
+
+ // With all peers connected we should get all hints that have sufficient value
+ let mut scid_aliases = HashSet::new();
+ scid_aliases.insert(chan_a.0.short_channel_id_alias.unwrap());
+ scid_aliases.insert(chan_b.0.short_channel_id_alias.unwrap());
+
+ match_invoice_routes(Some(1_000_000_000), &nodes[0], scid_aliases.clone());
+
+ // With only one sufficient-value peer connected we should only get its hint
+ scid_aliases.remove(&chan_b.0.short_channel_id_alias.unwrap());
+ nodes[0].node.peer_disconnected(&nodes[2].node.get_our_node_id(), false);
+ match_invoice_routes(Some(1_000_000_000), &nodes[0], scid_aliases.clone());
+
+ // If we don't have any sufficient-value peers connected we should get all hints with
+ // sufficient value, even though there is a connected insufficient-value peer.
+ scid_aliases.insert(chan_b.0.short_channel_id_alias.unwrap());
+ nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false);
+ match_invoice_routes(Some(1_000_000_000), &nodes[0], scid_aliases);
+ }
+