X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=lightning%2Fsrc%2Fln%2Ffunctional_test_utils.rs;h=a2d9631716c4c23098135a8f95ee37a1fc5a6949;hb=c80d9a74b5437dd7c82fab40806adeb995219fc2;hp=f48c9ec7059d2f7d07ad08d2498a2ce2f897337a;hpb=70ea1108646468335d085a862e18bca774632bf3;p=rust-lightning diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index f48c9ec7..a2d96317 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -956,7 +956,14 @@ macro_rules! unwrap_send_err { _ => panic!(), } }, - _ => panic!(), + &Err(PaymentSendFailure::PathParameterError(ref result)) if !$all_failed => { + assert_eq!(result.len(), 1); + match result[0] { + Err($type) => { $check }, + _ => panic!(), + } + }, + _ => {panic!()}, } } } @@ -1529,6 +1536,18 @@ pub struct ExpectedCloseEvent { pub reason: Option, } +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(); @@ -1964,6 +1983,18 @@ pub fn get_route(send_node: &Node, route_params: &RouteParameters) -> Result Result { + 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::>()), + 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.