Fix unused (import) warnings in `no-std` builds
[rust-lightning] / lightning / src / ln / functional_test_utils.rs
index d3d2e3322cafb79f58573d6e18aa7deb84672709..a2d9631716c4c23098135a8f95ee37a1fc5a6949 100644 (file)
@@ -1536,6 +1536,18 @@ pub struct ExpectedCloseEvent {
        pub reason: Option<ClosureReason>,
 }
 
+impl ExpectedCloseEvent {
+       pub fn from_id_reason(channel_id: ChannelId, discard_funding: bool, reason: ClosureReason) -> Self {
+               Self {
+                       channel_capacity_sats: None,
+                       channel_id: Some(channel_id),
+                       counterparty_node_id: None,
+                       discard_funding,
+                       reason: Some(reason),
+               }
+       }
+}
+
 /// Check that multiple channel closing events have been issued.
 pub fn check_closed_events(node: &Node, expected_close_events: &[ExpectedCloseEvent]) {
        let closed_events_count = expected_close_events.len();
@@ -1971,6 +1983,18 @@ pub fn get_route(send_node: &Node, route_params: &RouteParameters) -> Result<Rou
        )
 }
 
+/// Like `get_route` above, but adds a random CLTV offset to the final hop.
+pub fn find_route(send_node: &Node, route_params: &RouteParameters) -> Result<Route, msgs::LightningError> {
+       let scorer = TestScorer::new();
+       let keys_manager = TestKeysInterface::new(&[0u8; 32], bitcoin::network::constants::Network::Testnet);
+       let random_seed_bytes = keys_manager.get_secure_random_bytes();
+       router::find_route(
+               &send_node.node.get_our_node_id(), route_params, &send_node.network_graph,
+               Some(&send_node.node.list_usable_channels().iter().collect::<Vec<_>>()),
+               send_node.logger, &scorer, &Default::default(), &random_seed_bytes
+       )
+}
+
 /// Gets a route from the given sender to the node described in `payment_params`.
 ///
 /// Don't use this, use the identically-named function instead.