From 6b0d94a3029f74de3a7542cbba0d48c2f7e5866b Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 21 Sep 2023 01:44:23 +0000 Subject: [PATCH] Use `Default::default()` to construct `()` as a test scoring param In bindings, we can't use unbounded generic types, and thus have to rip out the `ScoreParams` and replace them with static `ProbabilisticScoringFeeParams` universally. To make this easier, using `Default::default()` everywhere allows the type to change out from under the test without the test needing to change. --- lightning/src/ln/channelmanager.rs | 10 +- lightning/src/ln/functional_test_utils.rs | 4 +- lightning/src/ln/functional_tests.rs | 6 +- lightning/src/ln/onion_route_tests.rs | 2 +- lightning/src/ln/payment_tests.rs | 12 +- lightning/src/ln/shutdown_tests.rs | 4 +- lightning/src/routing/router.rs | 210 +++++++++++----------- 7 files changed, 124 insertions(+), 124 deletions(-) diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 0cadbd41a..2a16a7622 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -10190,7 +10190,7 @@ mod tests { TEST_FINAL_CLTV, false), 100_000); let route = find_route( &nodes[0].node.get_our_node_id(), &route_params, &nodes[0].network_graph, - None, nodes[0].logger, &scorer, &(), &random_seed_bytes + None, nodes[0].logger, &scorer, &Default::default(), &random_seed_bytes ).unwrap(); nodes[0].node.send_spontaneous_payment(&route, Some(payment_preimage), RecipientOnionFields::spontaneous_empty(), PaymentId(payment_preimage.0)).unwrap(); @@ -10224,7 +10224,7 @@ mod tests { let payment_preimage = PaymentPreimage([42; 32]); let route = find_route( &nodes[0].node.get_our_node_id(), &route_params, &nodes[0].network_graph, - None, nodes[0].logger, &scorer, &(), &random_seed_bytes + None, nodes[0].logger, &scorer, &Default::default(), &random_seed_bytes ).unwrap(); let payment_hash = nodes[0].node.send_spontaneous_payment(&route, Some(payment_preimage), RecipientOnionFields::spontaneous_empty(), PaymentId(payment_preimage.0)).unwrap(); @@ -10281,7 +10281,7 @@ mod tests { ); let route = find_route( &nodes[0].node.get_our_node_id(), &route_params, &nodes[0].network_graph, - None, nodes[0].logger, &scorer, &(), &random_seed_bytes + None, nodes[0].logger, &scorer, &Default::default(), &random_seed_bytes ).unwrap(); let payment_id_2 = PaymentId([45; 32]); nodes[0].node.send_spontaneous_payment(&route, Some(payment_preimage), @@ -10332,7 +10332,7 @@ mod tests { let random_seed_bytes = chanmon_cfgs[1].keys_manager.get_secure_random_bytes(); let route = find_route( &payer_pubkey, &route_params, &network_graph, Some(&first_hops.iter().collect::>()), - nodes[0].logger, &scorer, &(), &random_seed_bytes + nodes[0].logger, &scorer, &Default::default(), &random_seed_bytes ).unwrap(); let test_preimage = PaymentPreimage([42; 32]); @@ -10377,7 +10377,7 @@ mod tests { let random_seed_bytes = chanmon_cfgs[1].keys_manager.get_secure_random_bytes(); let route = find_route( &payer_pubkey, &route_params, &network_graph, Some(&first_hops.iter().collect::>()), - nodes[0].logger, &scorer, &(), &random_seed_bytes + nodes[0].logger, &scorer, &Default::default(), &random_seed_bytes ).unwrap(); let test_preimage = PaymentPreimage([42; 32]); diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index f6684485d..a48c78f52 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -1854,7 +1854,7 @@ pub fn get_route(send_node: &Node, route_params: &RouteParameters) -> Result>()), - send_node.logger, &scorer, &(), &random_seed_bytes + send_node.logger, &scorer, &Default::default(), &random_seed_bytes ) } @@ -2506,7 +2506,7 @@ pub fn route_over_limit<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_rou let keys_manager = test_utils::TestKeysInterface::new(&seed, Network::Testnet); let random_seed_bytes = keys_manager.get_secure_random_bytes(); let route = router::get_route(&origin_node.node.get_our_node_id(), &route_params, &network_graph, - None, origin_node.logger, &scorer, &(), &random_seed_bytes).unwrap(); + None, origin_node.logger, &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 1); assert_eq!(route.paths[0].hops.len(), expected_route.len()); for (node, hop) in expected_route.iter().zip(route.paths[0].hops.iter()) { diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs index b252a352c..00df87875 100644 --- a/lightning/src/ln/functional_tests.rs +++ b/lightning/src/ln/functional_tests.rs @@ -7231,7 +7231,7 @@ fn test_check_htlc_underpaying() { TEST_FINAL_CLTV).with_bolt11_features(nodes[1].node.invoice_features()).unwrap(); let route_params = RouteParameters::from_payment_params_and_value(payment_params, 10_000); let route = get_route(&nodes[0].node.get_our_node_id(), &route_params, &nodes[0].network_graph.read_only(), - None, nodes[0].logger, &scorer, &(), &random_seed_bytes).unwrap(); + None, nodes[0].logger, &scorer, &Default::default(), &random_seed_bytes).unwrap(); let (_, our_payment_hash, _) = get_payment_preimage_hash!(nodes[0]); let our_payment_secret = nodes[1].node.create_inbound_payment_for_hash(our_payment_hash, Some(100_000), 7200, None).unwrap(); nodes[0].node.send_payment_with_route(&route, our_payment_hash, @@ -7489,12 +7489,12 @@ fn test_bump_penalty_txn_on_revoked_htlcs() { let random_seed_bytes = chanmon_cfgs[1].keys_manager.get_secure_random_bytes(); let route_params = RouteParameters::from_payment_params_and_value(payment_params, 3_000_000); let route = get_route(&nodes[0].node.get_our_node_id(), &route_params, &nodes[0].network_graph.read_only(), None, - nodes[0].logger, &scorer, &(), &random_seed_bytes).unwrap(); + nodes[0].logger, &scorer, &Default::default(), &random_seed_bytes).unwrap(); let payment_preimage = send_along_route(&nodes[0], route, &[&nodes[1]], 3_000_000).0; let payment_params = PaymentParameters::from_node_id(nodes[0].node.get_our_node_id(), 50).with_bolt11_features(nodes[0].node.invoice_features()).unwrap(); let route_params = RouteParameters::from_payment_params_and_value(payment_params, 3_000_000); let route = get_route(&nodes[1].node.get_our_node_id(), &route_params, &nodes[1].network_graph.read_only(), None, - nodes[0].logger, &scorer, &(), &random_seed_bytes).unwrap(); + nodes[0].logger, &scorer, &Default::default(), &random_seed_bytes).unwrap(); send_along_route(&nodes[1], route, &[&nodes[0]], 3_000_000); let revoked_local_txn = get_local_commitment_txn!(nodes[1], chan.2); diff --git a/lightning/src/ln/onion_route_tests.rs b/lightning/src/ln/onion_route_tests.rs index 3731c31c5..52ae29080 100644 --- a/lightning/src/ln/onion_route_tests.rs +++ b/lightning/src/ln/onion_route_tests.rs @@ -1052,7 +1052,7 @@ macro_rules! get_phantom_route { (get_route( &$nodes[0].node.get_our_node_id(), &route_params, &network_graph, Some(&$nodes[0].node.list_usable_channels().iter().collect::>()), - $nodes[0].logger, &scorer, &(), &[0u8; 32] + $nodes[0].logger, &scorer, &Default::default(), &[0u8; 32] ).unwrap(), phantom_route_hint.phantom_scid) } }} diff --git a/lightning/src/ln/payment_tests.rs b/lightning/src/ln/payment_tests.rs index 3def4e362..7a0d5c5ef 100644 --- a/lightning/src/ln/payment_tests.rs +++ b/lightning/src/ln/payment_tests.rs @@ -267,7 +267,7 @@ fn do_test_keysend_payments(public_node: bool, with_retry: bool) { let random_seed_bytes = chanmon_cfgs[1].keys_manager.get_secure_random_bytes(); let route = find_route( &payer_pubkey, &route_params, &network_graph, first_hops, - nodes[0].logger, &scorer, &(), &random_seed_bytes + nodes[0].logger, &scorer, &Default::default(), &random_seed_bytes ).unwrap(); { @@ -320,7 +320,7 @@ fn test_mpp_keysend() { let scorer = test_utils::TestScorer::new(); let random_seed_bytes = chanmon_cfgs[0].keys_manager.get_secure_random_bytes(); let route = find_route(&payer_pubkey, &route_params, &network_graph, None, nodes[0].logger, - &scorer, &(), &random_seed_bytes).unwrap(); + &scorer, &Default::default(), &random_seed_bytes).unwrap(); let payment_preimage = PaymentPreimage([42; 32]); let payment_secret = PaymentSecret(payment_preimage.0); @@ -1106,7 +1106,7 @@ fn get_ldk_payment_preimage() { let route = get_route( &nodes[0].node.get_our_node_id(), &route_params, &nodes[0].network_graph.read_only(), Some(&nodes[0].node.list_usable_channels().iter().collect::>()), nodes[0].logger, - &scorer, &(), &random_seed_bytes).unwrap(); + &scorer, &Default::default(), &random_seed_bytes).unwrap(); nodes[0].node.send_payment_with_route(&route, payment_hash, RecipientOnionFields::secret_only(payment_secret), PaymentId(payment_hash.0)).unwrap(); check_added_monitors!(nodes[0], 1); @@ -1750,9 +1750,9 @@ fn do_test_intercepted_payment(test: InterceptTest) { ]).unwrap() .with_bolt11_features(nodes[2].node.invoice_features()).unwrap(); let route_params = RouteParameters::from_payment_params_and_value(payment_params, amt_msat,); - let route = get_route( &nodes[0].node.get_our_node_id(), &route_params, - &nodes[0].network_graph.read_only(), None, nodes[0].logger, &scorer, &(), - &random_seed_bytes,).unwrap(); + let route = get_route(&nodes[0].node.get_our_node_id(), &route_params, + &nodes[0].network_graph.read_only(), None, nodes[0].logger, &scorer, &Default::default(), + &random_seed_bytes).unwrap(); let (payment_hash, payment_secret) = nodes[2].node.create_inbound_payment(Some(amt_msat), 60 * 60, None).unwrap(); nodes[0].node.send_payment_with_route(&route, payment_hash, diff --git a/lightning/src/ln/shutdown_tests.rs b/lightning/src/ln/shutdown_tests.rs index f105edc19..01f2837ab 100644 --- a/lightning/src/ln/shutdown_tests.rs +++ b/lightning/src/ln/shutdown_tests.rs @@ -315,12 +315,12 @@ fn updates_shutdown_wait() { let payment_params_1 = PaymentParameters::from_node_id(nodes[1].node.get_our_node_id(), TEST_FINAL_CLTV).with_bolt11_features(nodes[1].node.invoice_features()).unwrap(); let route_params = RouteParameters::from_payment_params_and_value(payment_params_1, 100_000); let route_1 = get_route(&nodes[0].node.get_our_node_id(), &route_params, - &nodes[0].network_graph.read_only(), None, &logger, &scorer, &(), &random_seed_bytes).unwrap(); + &nodes[0].network_graph.read_only(), None, &logger, &scorer, &Default::default(), &random_seed_bytes).unwrap(); let payment_params_2 = PaymentParameters::from_node_id(nodes[0].node.get_our_node_id(), TEST_FINAL_CLTV).with_bolt11_features(nodes[0].node.invoice_features()).unwrap(); let route_params = RouteParameters::from_payment_params_and_value(payment_params_2, 100_000); let route_2 = get_route(&nodes[1].node.get_our_node_id(), &route_params, - &nodes[1].network_graph.read_only(), None, &logger, &scorer, &(), &random_seed_bytes).unwrap(); + &nodes[1].network_graph.read_only(), None, &logger, &scorer, &Default::default(), &random_seed_bytes).unwrap(); unwrap_send_err!(nodes[0].node.send_payment_with_route(&route_1, payment_hash, RecipientOnionFields::secret_only(payment_secret), PaymentId(payment_hash.0) ), true, APIError::ChannelUnavailable {..}, {}); diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 258665c23..6e5c00e76 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -2705,7 +2705,7 @@ fn build_route_from_hops_internal( let scorer = HopScorer { our_node_id, hop_ids }; - get_route(our_node_pubkey, route_params, network_graph, None, logger, &scorer, &(), random_seed_bytes) + get_route(our_node_pubkey, route_params, network_graph, None, logger, &scorer, &Default::default(), random_seed_bytes) } #[cfg(test)] @@ -2801,14 +2801,14 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params.clone(), 0); if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route(&our_id, - &route_params, &network_graph.read_only(), None, Arc::clone(&logger), &scorer, &(), - &random_seed_bytes) { + &route_params, &network_graph.read_only(), None, Arc::clone(&logger), &scorer, + &Default::default(), &random_seed_bytes) { assert_eq!(err, "Cannot send a payment of 0 msat"); } else { panic!(); } let route_params = RouteParameters::from_payment_params_and_value(payment_params, 100); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths[0].hops.len(), 2); assert_eq!(route.paths[0].hops[0].pubkey, nodes[1]); @@ -2842,12 +2842,12 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value(payment_params, 100); if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route(&our_id, &route_params, &network_graph.read_only(), Some(&our_chans.iter().collect::>()), - Arc::clone(&logger), &scorer, &(), &random_seed_bytes) { + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes) { assert_eq!(err, "First hop cannot have our_node_pubkey as a destination."); } else { panic!(); } let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths[0].hops.len(), 2); } @@ -2958,8 +2958,8 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params, 199_999_999); if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route(&our_id, - &route_params, &network_graph.read_only(), None, Arc::clone(&logger), &scorer, &(), - &random_seed_bytes) { + &route_params, &network_graph.read_only(), None, Arc::clone(&logger), &scorer, + &Default::default(), &random_seed_bytes) { assert_eq!(err, "Failed to find a path to the given destination"); } else { panic!(); } @@ -2979,7 +2979,7 @@ mod tests { // A payment above the minimum should pass let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths[0].hops.len(), 2); } @@ -3064,7 +3064,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params.clone(), 60_000); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); // Overpay fees to hit htlc_minimum_msat. let overpaid_fees = route.paths[0].hops[0].fee_msat + route.paths[1].hops[0].fee_msat; // TODO: this could be better balanced to overpay 10k and not 15k. @@ -3110,7 +3110,7 @@ mod tests { }); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); // Fine to overpay for htlc_minimum_msat if it allows us to save fee. assert_eq!(route.paths.len(), 1); assert_eq!(route.paths[0].hops[0].short_channel_id, 12); @@ -3119,7 +3119,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value(payment_params, 50_000); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); // Not fine to overpay for htlc_minimum_msat if it requires paying more than fee on // the other channel. assert_eq!(route.paths.len(), 1); @@ -3166,8 +3166,8 @@ mod tests { // If all the channels require some features we don't understand, route should fail let route_params = RouteParameters::from_payment_params_and_value(payment_params, 100); if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route(&our_id, - &route_params, &network_graph.read_only(), None, Arc::clone(&logger), &scorer, &(), - &random_seed_bytes) { + &route_params, &network_graph.read_only(), None, Arc::clone(&logger), &scorer, + &Default::default(), &random_seed_bytes) { assert_eq!(err, "Failed to find a path to the given destination"); } else { panic!(); } @@ -3175,8 +3175,8 @@ mod tests { let our_chans = vec![get_channel_details(Some(42), nodes[7].clone(), InitFeatures::from_le_bytes(vec![0b11]), 250_000_000)]; let route = get_route(&our_id, &route_params, &network_graph.read_only(), - Some(&our_chans.iter().collect::>()), Arc::clone(&logger), &scorer, &(), - &random_seed_bytes).unwrap(); + Some(&our_chans.iter().collect::>()), Arc::clone(&logger), &scorer, + &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths[0].hops.len(), 2); assert_eq!(route.paths[0].hops[0].pubkey, nodes[7]); @@ -3213,8 +3213,8 @@ mod tests { // If all nodes require some features we don't understand, route should fail let route_params = RouteParameters::from_payment_params_and_value(payment_params, 100); if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route(&our_id, - &route_params, &network_graph.read_only(), None, Arc::clone(&logger), &scorer, &(), - &random_seed_bytes) { + &route_params, &network_graph.read_only(), None, Arc::clone(&logger), &scorer, + &Default::default(), &random_seed_bytes) { assert_eq!(err, "Failed to find a path to the given destination"); } else { panic!(); } @@ -3222,8 +3222,8 @@ mod tests { let our_chans = vec![get_channel_details(Some(42), nodes[7].clone(), InitFeatures::from_le_bytes(vec![0b11]), 250_000_000)]; let route = get_route(&our_id, &route_params, &network_graph.read_only(), - Some(&our_chans.iter().collect::>()), Arc::clone(&logger), &scorer, &(), - &random_seed_bytes).unwrap(); + Some(&our_chans.iter().collect::>()), Arc::clone(&logger), &scorer, + &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths[0].hops.len(), 2); assert_eq!(route.paths[0].hops[0].pubkey, nodes[7]); @@ -3257,7 +3257,7 @@ mod tests { let payment_params = PaymentParameters::from_node_id(nodes[0], 42); let route_params = RouteParameters::from_payment_params_and_value(payment_params, 100); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths[0].hops.len(), 3); assert_eq!(route.paths[0].hops[0].pubkey, nodes[1]); @@ -3287,8 +3287,8 @@ mod tests { let our_chans = vec![get_channel_details(Some(42), nodes[7].clone(), InitFeatures::from_le_bytes(vec![0b11]), 250_000_000)]; let route = get_route(&our_id, &route_params, &network_graph.read_only(), - Some(&our_chans.iter().collect::>()), Arc::clone(&logger), &scorer, &(), - &random_seed_bytes).unwrap(); + Some(&our_chans.iter().collect::>()), Arc::clone(&logger), &scorer, + &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths[0].hops.len(), 2); assert_eq!(route.paths[0].hops[0].pubkey, nodes[7]); @@ -3414,8 +3414,8 @@ mod tests { .with_route_hints(invalid_last_hops).unwrap(); let route_params = RouteParameters::from_payment_params_and_value(payment_params, 100); if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route(&our_id, - &route_params, &network_graph.read_only(), None, Arc::clone(&logger), &scorer, &(), - &random_seed_bytes) { + &route_params, &network_graph.read_only(), None, Arc::clone(&logger), &scorer, + &Default::default(), &random_seed_bytes) { assert_eq!(err, "Route hint cannot have the payee as the source."); } else { panic!(); } } @@ -3424,7 +3424,7 @@ mod tests { .with_route_hints(last_hops_multi_private_channels(&nodes)).unwrap(); let route_params = RouteParameters::from_payment_params_and_value(payment_params, 100); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths[0].hops.len(), 5); assert_eq!(route.paths[0].hops[0].pubkey, nodes[1]); @@ -3501,7 +3501,7 @@ mod tests { // Test handling of an empty RouteHint passed in Invoice. let route_params = RouteParameters::from_payment_params_and_value(payment_params, 100); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths[0].hops.len(), 5); assert_eq!(route.paths[0].hops[0].pubkey, nodes[1]); @@ -3609,7 +3609,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value(payment_params, 100); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths[0].hops.len(), 4); assert_eq!(route.paths[0].hops[0].pubkey, nodes[1]); @@ -3683,7 +3683,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value(payment_params, 100); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &[42u8; 32]).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &[42u8; 32]).unwrap(); assert_eq!(route.paths[0].hops.len(), 4); assert_eq!(route.paths[0].hops[0].pubkey, nodes[1]); @@ -3767,7 +3767,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value(payment_params, 100); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths[0].hops.len(), 5); assert_eq!(route.paths[0].hops[0].pubkey, nodes[1]); @@ -3823,8 +3823,8 @@ mod tests { .with_route_hints(last_hops.clone()).unwrap(); let route_params = RouteParameters::from_payment_params_and_value(payment_params, 100); let route = get_route(&our_id, &route_params, &network_graph.read_only(), - Some(&our_chans.iter().collect::>()), Arc::clone(&logger), &scorer, &(), - &random_seed_bytes).unwrap(); + Some(&our_chans.iter().collect::>()), Arc::clone(&logger), &scorer, + &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths[0].hops.len(), 2); assert_eq!(route.paths[0].hops[0].pubkey, nodes[3]); @@ -3849,7 +3849,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params.clone(), 100); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths[0].hops.len(), 4); assert_eq!(route.paths[0].hops[0].pubkey, nodes[1]); @@ -3885,7 +3885,7 @@ mod tests { // ...but still use 8 for larger payments as 6 has a variable feerate let route_params = RouteParameters::from_payment_params_and_value(payment_params, 2000); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths[0].hops.len(), 5); assert_eq!(route.paths[0].hops[0].pubkey, nodes[1]); @@ -3952,7 +3952,7 @@ mod tests { let network_graph = NetworkGraph::new(Network::Testnet, &logger); let route_params = RouteParameters::from_payment_params_and_value(payment_params, route_val); let route = get_route(&source_node_id, &route_params, &network_graph.read_only(), - Some(&our_chans.iter().collect::>()), &logger, &scorer, &(), + Some(&our_chans.iter().collect::>()), &logger, &scorer, &Default::default(), &random_seed_bytes); route } @@ -4078,7 +4078,7 @@ mod tests { payment_params.clone(), 250_000_001); if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route( &our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes) { + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes) { assert_eq!(err, "Failed to find a sufficient route to the given destination"); } else { panic!(); } } @@ -4088,7 +4088,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params.clone(), 250_000_000); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(),&random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 1); let path = route.paths.last().unwrap(); assert_eq!(path.hops.len(), 2); @@ -4121,7 +4121,7 @@ mod tests { if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route( &our_id, &route_params, &network_graph.read_only(), Some(&our_chans.iter().collect::>()), Arc::clone(&logger), &scorer, - &(), &random_seed_bytes) { + &Default::default(), &random_seed_bytes) { assert_eq!(err, "Failed to find a sufficient route to the given destination"); } else { panic!(); } } @@ -4131,8 +4131,8 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params.clone(), 200_000_000); let route = get_route(&our_id, &route_params, &network_graph.read_only(), - Some(&our_chans.iter().collect::>()), Arc::clone(&logger), &scorer, &(), - &random_seed_bytes).unwrap(); + Some(&our_chans.iter().collect::>()), Arc::clone(&logger), &scorer, + &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 1); let path = route.paths.last().unwrap(); assert_eq!(path.hops.len(), 2); @@ -4175,7 +4175,7 @@ mod tests { payment_params.clone(), 15_001); if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route( &our_id, &route_params, &network_graph.read_only(), None, Arc::clone(&logger), - &scorer, &(), &random_seed_bytes) { + &scorer, &Default::default(), &random_seed_bytes) { assert_eq!(err, "Failed to find a sufficient route to the given destination"); } else { panic!(); } } @@ -4185,7 +4185,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params.clone(), 15_000); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 1); let path = route.paths.last().unwrap(); assert_eq!(path.hops.len(), 2); @@ -4252,7 +4252,7 @@ mod tests { payment_params.clone(), 15_001); if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route( &our_id, &route_params, &network_graph.read_only(), None, Arc::clone(&logger), - &scorer, &(), &random_seed_bytes) { + &scorer, &Default::default(), &random_seed_bytes) { assert_eq!(err, "Failed to find a sufficient route to the given destination"); } else { panic!(); } } @@ -4262,7 +4262,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params.clone(), 15_000); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 1); let path = route.paths.last().unwrap(); assert_eq!(path.hops.len(), 2); @@ -4290,7 +4290,7 @@ mod tests { payment_params.clone(), 10_001); if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route( &our_id, &route_params, &network_graph.read_only(), None, Arc::clone(&logger), - &scorer, &(), &random_seed_bytes) { + &scorer, &Default::default(), &random_seed_bytes) { assert_eq!(err, "Failed to find a sufficient route to the given destination"); } else { panic!(); } } @@ -4300,7 +4300,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params.clone(), 10_000); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 1); let path = route.paths.last().unwrap(); assert_eq!(path.hops.len(), 2); @@ -4408,7 +4408,7 @@ mod tests { payment_params.clone(), 60_000); if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route( &our_id, &route_params, &network_graph.read_only(), None, Arc::clone(&logger), - &scorer, &(), &random_seed_bytes) { + &scorer, &Default::default(), &random_seed_bytes) { assert_eq!(err, "Failed to find a sufficient route to the given destination"); } else { panic!(); } } @@ -4418,7 +4418,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params.clone(), 49_000); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 1); let mut total_amount_paid_msat = 0; for path in &route.paths { @@ -4434,7 +4434,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params, 50_000); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 1); let mut total_amount_paid_msat = 0; for path in &route.paths { @@ -4485,7 +4485,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params, 50_000); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 1); let mut total_amount_paid_msat = 0; for path in &route.paths { @@ -4654,7 +4654,7 @@ mod tests { payment_params.clone(), 300_000); if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route( &our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes) { + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes) { assert_eq!(err, "Failed to find a sufficient route to the given destination"); } else { panic!(); } } @@ -4666,7 +4666,7 @@ mod tests { zero_payment_params, 100); if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route( &our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes) { + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes) { assert_eq!(err, "Can't find a route with no paths allowed."); } else { panic!(); } } @@ -4680,7 +4680,7 @@ mod tests { fail_payment_params, 250_000); if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route( &our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes) { + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes) { assert_eq!(err, "Failed to find a sufficient route to the given destination"); } else { panic!(); } } @@ -4691,7 +4691,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params.clone(), 250_000); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 3); let mut total_amount_paid_msat = 0; for path in &route.paths { @@ -4711,7 +4711,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params.clone(), 290_000); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 3); let mut total_amount_paid_msat = 0; for path in &route.paths { @@ -4885,7 +4885,7 @@ mod tests { payment_params.clone(), 350_000); if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route( &our_id, &route_params, &network_graph.read_only(), None, Arc::clone(&logger), - &scorer, &(), &random_seed_bytes) { + &scorer, &Default::default(), &random_seed_bytes) { assert_eq!(err, "Failed to find a sufficient route to the given destination"); } else { panic!(); } } @@ -4896,7 +4896,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params, 300_000); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 3); let mut total_amount_paid_msat = 0; @@ -5060,7 +5060,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params, 180_000); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 2); let mut total_value_transferred_msat = 0; @@ -5234,7 +5234,7 @@ mod tests { payment_params.clone(), 210_000); if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route( &our_id, &route_params, &network_graph.read_only(), None, Arc::clone(&logger), - &scorer, &(), &random_seed_bytes) { + &scorer, &Default::default(), &random_seed_bytes) { assert_eq!(err, "Failed to find a sufficient route to the given destination"); } else { panic!(); } } @@ -5243,7 +5243,7 @@ mod tests { // Now, attempt to route 200 sats (exact amount we can route). let route_params = RouteParameters::from_payment_params_and_value(payment_params, 200_000); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 2); let mut total_amount_paid_msat = 0; @@ -5346,7 +5346,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params, 100_000); let mut route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 2); route.paths.sort_by_key(|path| path.hops[0].short_channel_id); // Paths are manually ordered ordered by SCID, so: @@ -5468,7 +5468,7 @@ mod tests { payment_params.clone(), 150_000); if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route( &our_id, &route_params, &network_graph.read_only(), None, Arc::clone(&logger), - &scorer, &(), &random_seed_bytes) { + &scorer, &Default::default(), &random_seed_bytes) { assert_eq!(err, "Failed to find a sufficient route to the given destination"); } else { panic!(); } } @@ -5479,7 +5479,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params.clone(), 125_000); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 3); let mut total_amount_paid_msat = 0; for path in &route.paths { @@ -5495,7 +5495,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params, 90_000); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 2); let mut total_amount_paid_msat = 0; for path in &route.paths { @@ -5637,7 +5637,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params, 10_000); let route = get_route(&our_id, &route_params, &network.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 1); assert_eq!(route.paths[0].hops.len(), 3); @@ -5711,7 +5711,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params, 90_000); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 1); assert_eq!(route.paths[0].hops.len(), 2); @@ -5780,7 +5780,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params, 90_000); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 1); assert_eq!(route.paths[0].hops.len(), 2); @@ -5824,7 +5824,7 @@ mod tests { let route = get_route(&our_id, &route_params, &network_graph.read_only(), Some(&[ &get_channel_details(Some(3), nodes[0], channelmanager::provided_init_features(&config), 200_000), &get_channel_details(Some(2), nodes[0], channelmanager::provided_init_features(&config), 10_000), - ]), Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + ]), Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 1); assert_eq!(route.paths[0].hops.len(), 1); @@ -5838,7 +5838,7 @@ mod tests { let route = get_route(&our_id, &route_params, &network_graph.read_only(), Some(&[ &get_channel_details(Some(3), nodes[0], channelmanager::provided_init_features(&config), 50_000), &get_channel_details(Some(2), nodes[0], channelmanager::provided_init_features(&config), 50_000), - ]), Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + ]), Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 2); assert_eq!(route.paths[0].hops.len(), 1); assert_eq!(route.paths[1].hops.len(), 1); @@ -5872,7 +5872,7 @@ mod tests { &get_channel_details(Some(8), nodes[0], channelmanager::provided_init_features(&config), 50_000), &get_channel_details(Some(9), nodes[0], channelmanager::provided_init_features(&config), 50_000), &get_channel_details(Some(4), nodes[0], channelmanager::provided_init_features(&config), 1_000_000), - ]), Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + ]), Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 1); assert_eq!(route.paths[0].hops.len(), 1); @@ -5895,7 +5895,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params.clone(), 100); let route = get_route( &our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); let path = route.paths[0].hops.iter().map(|hop| hop.short_channel_id).collect::>(); assert_eq!(route.get_total_fees(), 100); @@ -5908,7 +5908,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params, 100); let route = get_route( &our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); let path = route.paths[0].hops.iter().map(|hop| hop.short_channel_id).collect::>(); assert_eq!(route.get_total_fees(), 300); @@ -5961,7 +5961,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params, 100); let route = get_route( &our_id, &route_params, &network_graph, None, Arc::clone(&logger), - &scorer, &(), &random_seed_bytes).unwrap(); + &scorer, &Default::default(), &random_seed_bytes).unwrap(); let path = route.paths[0].hops.iter().map(|hop| hop.short_channel_id).collect::>(); assert_eq!(route.get_total_fees(), 100); @@ -5971,7 +5971,7 @@ mod tests { // A different path to nodes[6] exists if channel 6 cannot be routed over. let scorer = BadChannelScorer { short_channel_id: 6 }; let route = get_route( &our_id, &route_params, &network_graph, None, Arc::clone(&logger), - &scorer, &(), &random_seed_bytes).unwrap(); + &scorer, &Default::default(), &random_seed_bytes).unwrap(); let path = route.paths[0].hops.iter().map(|hop| hop.short_channel_id).collect::>(); assert_eq!(route.get_total_fees(), 300); @@ -5981,7 +5981,7 @@ mod tests { // A path to nodes[6] does not exist if nodes[2] cannot be routed through. let scorer = BadNodeScorer { node_id: NodeId::from_pubkey(&nodes[2]) }; match get_route( &our_id, &route_params, &network_graph, None, Arc::clone(&logger), - &scorer, &(), &random_seed_bytes) { + &scorer, &Default::default(), &random_seed_bytes) { Err(LightningError { err, .. } ) => { assert_eq!(err, "Failed to find a path to the given destination"); }, @@ -6077,7 +6077,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( feasible_payment_params, 100); let route = get_route(&our_id, &route_params, &network_graph, None, Arc::clone(&logger), - &scorer, &(), &random_seed_bytes).unwrap(); + &scorer, &Default::default(), &random_seed_bytes).unwrap(); let path = route.paths[0].hops.iter().map(|hop| hop.short_channel_id).collect::>(); assert_ne!(path.len(), 0); @@ -6088,7 +6088,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( fail_payment_params, 100); match get_route(&our_id, &route_params, &network_graph, None, Arc::clone(&logger), &scorer, - &(), &random_seed_bytes) + &Default::default(), &random_seed_bytes) { Err(LightningError { err, .. } ) => { assert_eq!(err, "Failed to find a path to the given destination"); @@ -6116,12 +6116,12 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params.clone(), 100); assert!(get_route(&our_id, &route_params, &network_graph, None, Arc::clone(&logger), - &scorer, &(), &random_seed_bytes).is_ok()); + &scorer, &Default::default(), &random_seed_bytes).is_ok()); loop { let route_params = RouteParameters::from_payment_params_and_value( payment_params.clone(), 100); if let Ok(route) = get_route(&our_id, &route_params, &network_graph, None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes) + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes) { for chan in route.paths[0].hops.iter() { assert!(!payment_params.previously_failed_channels.contains(&chan.short_channel_id)); @@ -6148,7 +6148,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( feasible_payment_params, 100); let route = get_route(&our_id, &route_params, &network_graph, None, Arc::clone(&logger), - &scorer, &(), &random_seed_bytes).unwrap(); + &scorer, &Default::default(), &random_seed_bytes).unwrap(); let path = route.paths[0].hops.iter().map(|hop| hop.short_channel_id).collect::>(); assert!(path.len() == MAX_PATH_LENGTH_ESTIMATE.into()); @@ -6157,7 +6157,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( fail_payment_params, 100); match get_route(&our_id, &route_params, &network_graph, None, Arc::clone(&logger), &scorer, - &(), &random_seed_bytes) + &Default::default(), &random_seed_bytes) { Err(LightningError { err, .. } ) => { assert_eq!(err, "Failed to find a path to the given destination"); @@ -6179,7 +6179,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params.clone(), 100); let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 1); let cltv_expiry_deltas_before = route.paths[0].hops.iter().map(|h| h.cltv_expiry_delta).collect::>(); @@ -6216,7 +6216,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params.clone(), 100); let mut route = get_route(&our_id, &route_params, &network_graph, None, - Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); + Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes).unwrap(); add_random_cltv_offset(&mut route, &payment_params, &network_graph, &random_seed_bytes); let mut path_plausibility = vec![]; @@ -6486,7 +6486,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params, max_htlc_msat + 1); if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route(&our_id, - &route_params, &netgraph, None, Arc::clone(&logger), &scorer, &(), + &route_params, &netgraph, None, Arc::clone(&logger), &scorer, &Default::default(), &random_seed_bytes) { assert_eq!(err, "Failed to find a sufficient route to the given destination"); @@ -6501,7 +6501,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params, max_htlc_msat + 1); let route = get_route(&our_id, &route_params, &netgraph, None, Arc::clone(&logger), - &scorer, &(), &random_seed_bytes).unwrap(); + &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 2); assert!(route.paths[0].hops.last().unwrap().fee_msat <= max_htlc_msat); assert!(route.paths[1].hops.last().unwrap().fee_msat <= max_htlc_msat); @@ -6557,8 +6557,8 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params, amt_msat); let route = get_route(&our_node_id, &route_params, &network_graph.read_only(), - Some(&first_hop.iter().collect::>()), Arc::clone(&logger), &scorer, &(), - &random_seed_bytes).unwrap(); + Some(&first_hop.iter().collect::>()), Arc::clone(&logger), &scorer, + &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 2); assert!(route.paths[0].hops.last().unwrap().fee_msat <= max_htlc_msat); assert!(route.paths[1].hops.last().unwrap().fee_msat <= max_htlc_msat); @@ -6571,8 +6571,8 @@ mod tests { get_channel_details(Some(43), intermed_node_id, InitFeatures::from_le_bytes(vec![0b11]), amt_msat - 10), ]; let route = get_route(&our_node_id, &route_params, &network_graph.read_only(), - Some(&first_hops.iter().collect::>()), Arc::clone(&logger), &scorer, &(), - &random_seed_bytes).unwrap(); + Some(&first_hops.iter().collect::>()), Arc::clone(&logger), &scorer, + &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 2); assert!(route.paths[0].hops.last().unwrap().fee_msat <= max_htlc_msat); assert!(route.paths[1].hops.last().unwrap().fee_msat <= max_htlc_msat); @@ -6603,8 +6603,8 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params, amt_msat); let route = get_route(&our_node_id, &route_params, &network_graph.read_only(), - Some(&first_hops.iter().collect::>()), Arc::clone(&logger), &scorer, &(), - &random_seed_bytes).unwrap(); + Some(&first_hops.iter().collect::>()), Arc::clone(&logger), &scorer, + &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 2); assert!(route.paths[0].hops.last().unwrap().fee_msat <= max_htlc_msat); assert!(route.paths[1].hops.last().unwrap().fee_msat <= max_htlc_msat); @@ -6802,7 +6802,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params, 1001); let route = get_route(&our_id, &route_params, &network_graph, None, Arc::clone(&logger), - &scorer, &(), &random_seed_bytes).unwrap(); + &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 1); assert_eq!(route.paths[0].hops.len(), 2); @@ -6857,7 +6857,7 @@ mod tests { (blinded_payinfo.clone(), invalid_blinded_path_2)]); let route_params = RouteParameters::from_payment_params_and_value(payment_params, 1001); match get_route(&our_id, &route_params, &network_graph, None, Arc::clone(&logger), - &scorer, &(), &random_seed_bytes) + &scorer, &Default::default(), &random_seed_bytes) { Err(LightningError { err, .. }) => { assert_eq!(err, "1-hop blinded paths must all have matching introduction node ids"); @@ -6869,7 +6869,7 @@ mod tests { let payment_params = PaymentParameters::blinded(vec![(blinded_payinfo.clone(), invalid_blinded_path.clone())]); let route_params = RouteParameters::from_payment_params_and_value(payment_params, 1001); match get_route(&our_id, &route_params, &network_graph, None, Arc::clone(&logger), &scorer, - &(), &random_seed_bytes) + &Default::default(), &random_seed_bytes) { Err(LightningError { err, .. }) => { assert_eq!(err, "Cannot generate a route to blinded paths if we are the introduction node to all of them"); @@ -6882,7 +6882,7 @@ mod tests { let payment_params = PaymentParameters::blinded(vec![(blinded_payinfo, invalid_blinded_path)]); let route_params = RouteParameters::from_payment_params_and_value(payment_params, 1001); match get_route(&our_id, &route_params, &network_graph, None, Arc::clone(&logger), &scorer, - &(), &random_seed_bytes) + &Default::default(), &random_seed_bytes) { Err(LightningError { err, .. }) => { assert_eq!(err, "0-hop blinded path provided"); @@ -6936,7 +6936,7 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value(payment_params, 100_000); let route = get_route(&our_id, &route_params, &network_graph, None, Arc::clone(&logger), - &scorer, &(), &random_seed_bytes).unwrap(); + &scorer, &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 2); let mut total_amount_paid_msat = 0; for path in route.paths.into_iter() { @@ -7025,8 +7025,8 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params.clone(), amt_msat); if let Err(LightningError { err, .. }) = get_route(&nodes[0], &route_params, &netgraph, - Some(&first_hops.iter().collect::>()), Arc::clone(&logger), &scorer, &(), - &random_seed_bytes) { + Some(&first_hops.iter().collect::>()), Arc::clone(&logger), &scorer, + &Default::default(), &random_seed_bytes) { assert_eq!(err, "Failed to find a path to the given destination"); } else { panic!("Expected error") } @@ -7035,8 +7035,8 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params, amt_minus_blinded_path_fee); let route = get_route(&nodes[0], &route_params, &netgraph, - Some(&first_hops.iter().collect::>()), Arc::clone(&logger), &scorer, &(), - &random_seed_bytes).unwrap(); + Some(&first_hops.iter().collect::>()), Arc::clone(&logger), &scorer, + &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.get_total_fees(), blinded_payinfo.fee_base_msat as u64); assert_eq!(route.get_total_amount(), amt_minus_blinded_path_fee); } @@ -7104,8 +7104,8 @@ mod tests { let route_params = RouteParameters::from_payment_params_and_value( payment_params, amt_msat); let route = get_route(&nodes[0], &route_params, &netgraph, - Some(&first_hops.iter().collect::>()), Arc::clone(&logger), &scorer, &(), - &random_seed_bytes).unwrap(); + Some(&first_hops.iter().collect::>()), Arc::clone(&logger), &scorer, + &Default::default(), &random_seed_bytes).unwrap(); assert_eq!(route.get_total_fees(), blinded_payinfo.fee_base_msat as u64); assert_eq!(route.get_total_amount(), amt_msat); } @@ -7320,15 +7320,15 @@ pub mod benches { let logger = TestLogger::new(); let network_graph = bench_utils::read_network_graph(&logger).unwrap(); let scorer = FixedPenaltyScorer::with_penalty(0); - generate_routes(bench, &network_graph, scorer, &(), Bolt11InvoiceFeatures::empty(), 0, - "generate_routes_with_zero_penalty_scorer"); + generate_routes(bench, &network_graph, scorer, &Default::default(), + Bolt11InvoiceFeatures::empty(), 0, "generate_routes_with_zero_penalty_scorer"); } pub fn generate_mpp_routes_with_zero_penalty_scorer(bench: &mut Criterion) { let logger = TestLogger::new(); let network_graph = bench_utils::read_network_graph(&logger).unwrap(); let scorer = FixedPenaltyScorer::with_penalty(0); - generate_routes(bench, &network_graph, scorer, &(), + generate_routes(bench, &network_graph, scorer, &Default::default(), channelmanager::provided_invoice_features(&UserConfig::default()), 0, "generate_mpp_routes_with_zero_penalty_scorer"); } -- 2.39.5