From 9073b8dfba50fecac1b8c9c529c21140952ff03a Mon Sep 17 00:00:00 2001 From: Lalit mohan sharma Date: Sat, 4 Feb 2023 23:18:30 +0530 Subject: [PATCH 01/15] first commit --- lightning/src/routing/router.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 950384d957e..01adc845dcb 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1270,6 +1270,13 @@ where L::Target: Logger { // around again with a higher amount. if !contributes_sufficient_value || exceeds_max_path_length || exceeds_cltv_delta_limit || payment_failed_on_this_channel { + if let Some(first_hops) = first_hops { // **** + for hop in first_hops { // **** + let _channel_id = hop.channel_id; + } + log_trace!(logger, "first Hop is excluded because unfulfilling condition"); // commit + + } // Path isn't useful, ignore it and move on. } else if may_overpay_to_meet_path_minimum_msat { hit_minimum_limit = true; From 02dddb4e14ba1ece2bad128531ec79ddff4bb69e Mon Sep 17 00:00:00 2001 From: Lalitmohansharma1 Date: Sun, 5 Feb 2023 02:19:34 +0530 Subject: [PATCH 02/15] second commit --- lightning/src/routing/router.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 01adc845dcb..d6ce868388d 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1270,11 +1270,11 @@ where L::Target: Logger { // around again with a higher amount. if !contributes_sufficient_value || exceeds_max_path_length || exceeds_cltv_delta_limit || payment_failed_on_this_channel { - if let Some(first_hops) = first_hops { // **** - for hop in first_hops { // **** + if let Some(first_hops) = first_hops { // for only first hop it will log feedback + for hop in first_hops { let _channel_id = hop.channel_id; } - log_trace!(logger, "first Hop is excluded because unfulfilling condition"); // commit + log_trace!(logger, "first Hop is excluded because unfulfilling condition"); } // Path isn't useful, ignore it and move on. From 0312c2bf65f708409a2d6193debb420d258154ca Mon Sep 17 00:00:00 2001 From: lalit mohan sharma <78810405+Bolt-12@users.noreply.github.com> Date: Sun, 5 Feb 2023 22:15:56 +0530 Subject: [PATCH 03/15] original --- lightning/src/routing/router.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index d6ce868388d..950384d957e 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1270,13 +1270,6 @@ where L::Target: Logger { // around again with a higher amount. if !contributes_sufficient_value || exceeds_max_path_length || exceeds_cltv_delta_limit || payment_failed_on_this_channel { - if let Some(first_hops) = first_hops { // for only first hop it will log feedback - for hop in first_hops { - let _channel_id = hop.channel_id; - } - log_trace!(logger, "first Hop is excluded because unfulfilling condition"); - - } // Path isn't useful, ignore it and move on. } else if may_overpay_to_meet_path_minimum_msat { hit_minimum_limit = true; From 3cdb8edaae6217cb8b91c0389fe5977c8fb6a282 Mon Sep 17 00:00:00 2001 From: Lalitmohansharma1 Date: Sun, 5 Feb 2023 22:32:16 +0530 Subject: [PATCH 04/15] first logging --- lightning/src/routing/router.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index d6ce868388d..950384d957e 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1270,13 +1270,6 @@ where L::Target: Logger { // around again with a higher amount. if !contributes_sufficient_value || exceeds_max_path_length || exceeds_cltv_delta_limit || payment_failed_on_this_channel { - if let Some(first_hops) = first_hops { // for only first hop it will log feedback - for hop in first_hops { - let _channel_id = hop.channel_id; - } - log_trace!(logger, "first Hop is excluded because unfulfilling condition"); - - } // Path isn't useful, ignore it and move on. } else if may_overpay_to_meet_path_minimum_msat { hit_minimum_limit = true; From cfe611a9fc769b884fbdeee181910f449605b227 Mon Sep 17 00:00:00 2001 From: Lalitmohansharma1 Date: Sun, 5 Feb 2023 22:41:13 +0530 Subject: [PATCH 05/15] fifth commit --- lightning/src/routing/router.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 950384d957e..5779a18482c 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1270,6 +1270,13 @@ where L::Target: Logger { // around again with a higher amount. if !contributes_sufficient_value || exceeds_max_path_length || exceeds_cltv_delta_limit || payment_failed_on_this_channel { + if let Some(first_hops) = first_hops { // for only first hop it will log feedback + for hop in first_hops { + let _channel_id = hop.channel_id; + } + log_trace!(logger, "first Hop is excluded because unfulfilling condition"); + + } // Path isn't useful, ignore it and move on. } else if may_overpay_to_meet_path_minimum_msat { hit_minimum_limit = true; From 5bd77085359d8e489a5b0d7641e9ef56886d4264 Mon Sep 17 00:00:00 2001 From: Lalitmohansharma1 Date: Sun, 5 Feb 2023 23:27:00 +0530 Subject: [PATCH 06/15] third commit --- lightning/src/routing/router.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 5779a18482c..d9bb4fa98d9 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1275,7 +1275,6 @@ where L::Target: Logger { let _channel_id = hop.channel_id; } log_trace!(logger, "first Hop is excluded because unfulfilling condition"); - } // Path isn't useful, ignore it and move on. } else if may_overpay_to_meet_path_minimum_msat { From 87eef3f50ae85e42030ffe163acbfdb2c4a916d1 Mon Sep 17 00:00:00 2001 From: Lalitmohansharma1 Date: Thu, 9 Feb 2023 23:36:29 +0530 Subject: [PATCH 07/15] fourth commit --- lightning/src/routing/router.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index d9bb4fa98d9..040f39e6976 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1270,13 +1270,14 @@ where L::Target: Logger { // around again with a higher amount. if !contributes_sufficient_value || exceeds_max_path_length || exceeds_cltv_delta_limit || payment_failed_on_this_channel { - if let Some(first_hops) = first_hops { // for only first hop it will log feedback - for hop in first_hops { - let _channel_id = hop.channel_id; + let target = first_hop_targets.get(&NodeId::from_pubkey(&our_node_pubkey)).unwrap(); + for channel_details in target { + if let Some(short_channel_id_target) = channel_details.short_channel_id { + if short_channel_id == short_channel_id_target { + log_trace!(logger, "first Hop of node id {our_node_id} is excluded due to a failed requirement."); + } } - log_trace!(logger, "first Hop is excluded because unfulfilling condition"); - } - // Path isn't useful, ignore it and move on. + } } else if may_overpay_to_meet_path_minimum_msat { hit_minimum_limit = true; } else if over_path_minimum_msat { From 4a2c289770d0f2da7bd4ec7297cce0f00103358b Mon Sep 17 00:00:00 2001 From: Lalitmohansharma1 Date: Sat, 11 Feb 2023 16:37:19 +0530 Subject: [PATCH 08/15] sixth commit --- lightning/src/routing/router.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index b9a1bad0574..cee0e77af32 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1271,7 +1271,7 @@ where L::Target: Logger { for channel_details in target { if let Some(short_channel_id_target) = channel_details.short_channel_id { if short_channel_id == short_channel_id_target { - log_trace!(logger, "first Hop of node id {our_node_id} is excluded due to a failed requirement."); + log_trace!(logger, "first Hop of node id is excluded due to a failed requirement."); } } } From a8781ca11376e57eadaef0e021929bb47c551766 Mon Sep 17 00:00:00 2001 From: Lalitmohansharma1 Date: Sat, 11 Feb 2023 16:53:11 +0530 Subject: [PATCH 09/15] seventh commit --- lightning/src/routing/router.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index cee0e77af32..bd72c44f377 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1267,11 +1267,12 @@ where L::Target: Logger { // around again with a higher amount. if !contributes_sufficient_value || exceeds_max_path_length || exceeds_cltv_delta_limit || payment_failed_on_this_channel { + let our_node_id = NodeId::from_pubkey(&our_node_pubkey); let target = first_hop_targets.get(&NodeId::from_pubkey(&our_node_pubkey)).unwrap(); for channel_details in target { if let Some(short_channel_id_target) = channel_details.short_channel_id { if short_channel_id == short_channel_id_target { - log_trace!(logger, "first Hop of node id is excluded due to a failed requirement."); + log_trace!(logger, "first Hop of node id {our_node_id} is excluded due to a failed requirement."); } } } From 0e5e8a66a044f6b747064554cc28ba5b3e2d516c Mon Sep 17 00:00:00 2001 From: Lalitmohansharma1 Date: Wed, 15 Feb 2023 00:10:11 +0530 Subject: [PATCH 10/15] eight commit --- lightning/src/routing/router.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index bd72c44f377..73ef0977239 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1267,15 +1267,30 @@ where L::Target: Logger { // around again with a higher amount. if !contributes_sufficient_value || exceeds_max_path_length || exceeds_cltv_delta_limit || payment_failed_on_this_channel { - let our_node_id = NodeId::from_pubkey(&our_node_pubkey); - let target = first_hop_targets.get(&NodeId::from_pubkey(&our_node_pubkey)).unwrap(); + let empty_vec: Vec<&ChannelDetails> = Vec::new(); + let target = match first_hop_targets.get(&NodeId::from_pubkey(&our_node_pubkey)) { + Some(value) => value, + None => { + &empty_vec + } + }; for channel_details in target { if let Some(short_channel_id_target) = channel_details.short_channel_id { - if short_channel_id == short_channel_id_target { - log_trace!(logger, "first Hop of node id {our_node_id} is excluded due to a failed requirement."); + if short_channel_id == short_channel_id_target { // short_channel_id is hop id of candidate. + if !contributes_sufficient_value { + log_trace!(logger, "First Hop {short_channel_id} is excluded due to insufficient balance"); + } else if exceeds_max_path_length { + log_trace!(logger, "First Hop {short_channel_id} is excluded due to candidate hop excluded max path length"); + } else if exceeds_cltv_delta_limit { + log_trace!(logger, "First Hop {short_channel_id} is excluded beacause it exceed the maximum total cltv expiry limit"); + } else if payment_failed_on_this_channel { + log_trace!(logger, "First Hop {short_channel_id} is excluded beacause it was failed previously"); + } + } } } + // Path isn't useful, ignore it and move on. } else if may_overpay_to_meet_path_minimum_msat { hit_minimum_limit = true; } else if over_path_minimum_msat { From 8d2a85d75734a35fee99e53475f0649a06592909 Mon Sep 17 00:00:00 2001 From: Lalitmohansharma1 Date: Wed, 15 Feb 2023 22:14:20 +0530 Subject: [PATCH 11/15] ninth --- lightning/src/routing/router.rs | 36 +++++++++++++++------------------ 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 27f5d3ed429..1dc24f71682 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1243,27 +1243,23 @@ where L::Target: Logger { // around again with a higher amount. if !contributes_sufficient_value || exceeds_max_path_length || exceeds_cltv_delta_limit || payment_failed_on_this_channel { - let empty_vec: Vec<&ChannelDetails> = Vec::new(); - let target = match first_hop_targets.get(&NodeId::from_pubkey(&our_node_pubkey)) { - Some(value) => value, - None => { - &empty_vec - } - }; - for channel_details in target { - if let Some(short_channel_id_target) = channel_details.short_channel_id { - if short_channel_id == short_channel_id_target { // short_channel_id is hop id of candidate. - if !contributes_sufficient_value { - log_trace!(logger, "First Hop {short_channel_id} is excluded due to insufficient balance"); - } else if exceeds_max_path_length { - log_trace!(logger, "First Hop {short_channel_id} is excluded due to candidate hop excluded max path length"); - } else if exceeds_cltv_delta_limit { - log_trace!(logger, "First Hop {short_channel_id} is excluded beacause it exceed the maximum total cltv expiry limit"); - } else if payment_failed_on_this_channel { - log_trace!(logger, "First Hop {short_channel_id} is excluded beacause it was failed previously"); + let mut is_first_hop = true; + if let Some(target) = first_hop_targets.get(&NodeId::from_pubkey(&our_node_pubkey)){ + for channel_details in target { + if let Some(short_channel_id_target) = channel_details.short_channel_id{ + if short_channel_id_target == short_channel_id { // short_channel_id is hop id of candidate. + if is_first_hop && !contributes_sufficient_value { + log_trace!(logger, "First Hop {short_channel_id} is excluded due to insufficient value"); + } else if is_first_hop && exceeds_max_path_length { + log_trace!(logger, "First Hop {short_channel_id} is excluded due to candidate hop excluded max path length"); + } else if is_first_hop && exceeds_cltv_delta_limit { + log_trace!(logger, "First Hop {short_channel_id} is excluded beacause it exceed the maximum total cltv expiry limit"); + } else if is_first_hop && payment_failed_on_this_channel { + log_trace!(logger, "First Hop {short_channel_id} is excluded beacause it was failed previously"); + } + is_first_hop = false; } - - } + } } } // Path isn't useful, ignore it and move on. From 6da0e0683fec994e9d79860125306c08c1893916 Mon Sep 17 00:00:00 2001 From: Lalitmohansharma1 Date: Mon, 20 Feb 2023 15:33:56 +0530 Subject: [PATCH 12/15] access hashmap --- lightning/src/routing/router.rs | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 1dc24f71682..3f3c36e0a73 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1244,21 +1244,24 @@ where L::Target: Logger { if !contributes_sufficient_value || exceeds_max_path_length || exceeds_cltv_delta_limit || payment_failed_on_this_channel { let mut is_first_hop = true; - if let Some(target) = first_hop_targets.get(&NodeId::from_pubkey(&our_node_pubkey)){ - for channel_details in target { - if let Some(short_channel_id_target) = channel_details.short_channel_id{ - if short_channel_id_target == short_channel_id { // short_channel_id is hop id of candidate. - if is_first_hop && !contributes_sufficient_value { - log_trace!(logger, "First Hop {short_channel_id} is excluded due to insufficient value"); - } else if is_first_hop && exceeds_max_path_length { - log_trace!(logger, "First Hop {short_channel_id} is excluded due to candidate hop excluded max path length"); - } else if is_first_hop && exceeds_cltv_delta_limit { - log_trace!(logger, "First Hop {short_channel_id} is excluded beacause it exceed the maximum total cltv expiry limit"); - } else if is_first_hop && payment_failed_on_this_channel { - log_trace!(logger, "First Hop {short_channel_id} is excluded beacause it was failed previously"); + // if let Some(target) = first_hop_targets.get(&NodeId::from_pubkey(&our_node_pubkey)) { + for (key ,value) in &first_hop_targets { + if (key == &NodeId::from_pubkey(&our_node_pubkey)) { + for channel_details in value { + if let Some(short_channel_id_target) = channel_details.short_channel_id{ + if short_channel_id_target == short_channel_id { // short_channel_id is hop id of candidate. + if is_first_hop && !contributes_sufficient_value { + log_trace!(logger, "First Hop {short_channel_id} is excluded due to insufficient value"); + } else if is_first_hop && exceeds_max_path_length { + log_trace!(logger, "First Hop {short_channel_id} is excluded due to candidate hop excluded max path length"); + } else if is_first_hop && exceeds_cltv_delta_limit { + log_trace!(logger, "First Hop {short_channel_id} is excluded beacause it exceed the maximum total cltv expiry limit"); + } else if is_first_hop && payment_failed_on_this_channel { + log_trace!(logger, "First Hop {short_channel_id} is excluded beacause it was failed previously"); + } + is_first_hop = false; } - is_first_hop = false; - } + } } } } From 9bc34a15a001b747181f92021df0407f732d4770 Mon Sep 17 00:00:00 2001 From: Lalitmohansharma1 Date: Wed, 1 Mar 2023 15:47:46 +0530 Subject: [PATCH 13/15] improving hashmap conditions --- lightning/src/routing/router.rs | 40 ++++++++++++++++----------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 3da725df483..ed8fcd9f39d 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1243,28 +1243,26 @@ where L::Target: Logger { // around again with a higher amount. if !contributes_sufficient_value || exceeds_max_path_length || exceeds_cltv_delta_limit || payment_failed_on_this_channel { + + let logger_test = crate::util::test_utils::TestLogger::new(); let mut is_first_hop = true; - // if let Some(target) = first_hop_targets.get(&NodeId::from_pubkey(&our_node_pubkey)) { - for (key ,value) in &first_hop_targets { - if (key == &NodeId::from_pubkey(&our_node_pubkey)) { - for channel_details in value { - if let Some(short_channel_id_target) = channel_details.short_channel_id{ - if short_channel_id_target == short_channel_id { // short_channel_id is hop id of candidate. - if is_first_hop && !contributes_sufficient_value { - log_trace!(logger, "First Hop {short_channel_id} is excluded due to insufficient value"); - } else if is_first_hop && exceeds_max_path_length { - log_trace!(logger, "First Hop {short_channel_id} is excluded due to candidate hop excluded max path length"); - } else if is_first_hop && exceeds_cltv_delta_limit { - log_trace!(logger, "First Hop {short_channel_id} is excluded beacause it exceed the maximum total cltv expiry limit"); - } else if is_first_hop && payment_failed_on_this_channel { - log_trace!(logger, "First Hop {short_channel_id} is excluded beacause it was failed previously"); - } - is_first_hop = false; - } - } - } - } - } + for (key , _channel) in &first_hop_targets { + if key == &$dest_node_id { + if is_first_hop && !contributes_sufficient_value { + log_trace!(logger, "First Hop {} is excluded due to insufficient value", short_channel_id); + + } else if is_first_hop && exceeds_max_path_length { + log_trace!(logger, "First Hop {} is excluded due to candidate hop excluded max path length", short_channel_id); + + } else if is_first_hop && exceeds_cltv_delta_limit { + log_trace!(logger, "First Hop {} is excluded beacause it exceed the maximum total cltv expiry limit" , short_channel_id); + + } else if is_first_hop && payment_failed_on_this_channel { + log_trace!(logger, "First Hop {} is excluded beacause it was failed previously" , short_channel_id); + } + is_first_hop = false; + } // commit + } // Path isn't useful, ignore it and move on. } else if may_overpay_to_meet_path_minimum_msat { hit_minimum_limit = true; From 4364e186fded45a41d31a2d596cfcc278822d834 Mon Sep 17 00:00:00 2001 From: Lalitmohansharma1 Date: Sat, 4 Mar 2023 19:24:29 +0530 Subject: [PATCH 14/15] correction --- lightning/src/routing/router.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 1865694cf88..6769ab684c7 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1296,8 +1296,7 @@ where L::Target: Logger { // around again with a higher amount. if !contributes_sufficient_value || exceeds_max_path_length || exceeds_cltv_delta_limit || payment_failed_on_this_channel { - - let logger_test = crate::util::test_utils::TestLogger::new(); + let mut is_first_hop = true; for (key , _channel) in &first_hop_targets { if key == &$dest_node_id { From 592f6156d14f39f1e95c24024d80366bccf83770 Mon Sep 17 00:00:00 2001 From: Lalitmohansharma1 Date: Thu, 16 Mar 2023 13:59:05 +0530 Subject: [PATCH 15/15] test function --- lightning/src/routing/router.rs | 67 +++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 6769ab684c7..338e9149262 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1303,13 +1303,13 @@ where L::Target: Logger { if is_first_hop && !contributes_sufficient_value { log_trace!(logger, "First Hop {} is excluded due to insufficient value", short_channel_id); - } else if is_first_hop && exceeds_max_path_length { + } if is_first_hop && exceeds_max_path_length { log_trace!(logger, "First Hop {} is excluded due to candidate hop excluded max path length", short_channel_id); - } else if is_first_hop && exceeds_cltv_delta_limit { + } if is_first_hop && exceeds_cltv_delta_limit { log_trace!(logger, "First Hop {} is excluded beacause it exceed the maximum total cltv expiry limit" , short_channel_id); - } else if is_first_hop && payment_failed_on_this_channel { + } if is_first_hop && payment_failed_on_this_channel { log_trace!(logger, "First Hop {} is excluded beacause it was failed previously" , short_channel_id); } is_first_hop = false; @@ -3831,7 +3831,66 @@ mod tests { assert_eq!(total_amount_paid_msat, 50_000); } } - + + #[test] + fn test_my_logging_function() { // commit + let (secp_ctx, network_graph, gossip_sync, _, logger) = build_graph(); + let (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx); + let scorer = ln_test_utils::TestScorer::with_penalty(0); + let keys_manager = ln_test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet); + let random_seed_bytes = keys_manager.get_secure_random_bytes(); + let payment_params = PaymentParameters::from_node_id(nodes[2], 42); + let logger = crate::util::test_utils::TestLogger::new(); + + update_channel(&gossip_sync, &secp_ctx, &our_privkey, UnsignedChannelUpdate { + chain_hash: genesis_block(Network::Testnet).header.block_hash(), + short_channel_id: 1, + timestamp: 2, + flags: 0, + cltv_expiry_delta: 0, + htlc_minimum_msat: 0, + htlc_maximum_msat: 100_000, + fee_base_msat: 1_000_000, + fee_proportional_millionths: 0, + excess_data: Vec::new() + }); + update_channel(&gossip_sync, &secp_ctx, &privkeys[0], UnsignedChannelUpdate { + chain_hash: genesis_block(Network::Testnet).header.block_hash(), + short_channel_id: 3, + timestamp: 2, + flags: 0, + cltv_expiry_delta: 0, + htlc_minimum_msat: 0, + htlc_maximum_msat: 50_000, + fee_base_msat: 0, + fee_proportional_millionths: 0, + excess_data: Vec::new() + }); + + // we can make four test for different condition or all condition in diffrent tests. + let is_first_hop = true; + let contributes_sufficient_value = false ; // for contributes_suffiecient value , understand where this value came from. what is contribute_sufficent value. + + let exceeds_max_path_length = false; + let exceeds_cltv_delta_limit = false; + let payment_failed_on_this_channel = false; + + // For this test to run I want short_channel_id , dest_node_id . + let route = get_route(&our_id, &payment_params, &network_graph.read_only(), None, 49_000, 42, &logger, &scorer, &random_seed_bytes).unwrap(); + + // Retrieve the log message from TestLogger + let lines = logger.lines.lock().unwrap(); + let mut log_output = String::new(); + for ((module, file), line) in &*lines { + log_output.push_str(&format!("{} [{}] {}: {}\n", line, module, line, file)); + } + // Check for expected messages in the log output + assert!(log_output.contains("First Hop 3 is excluded due to insufficient value")); // + // assert_log_contains(log_ouptuts , 1); + } + + + #[test] fn simple_mpp_route_test() { let (secp_ctx, network_graph, gossip_sync, _, logger) = build_graph();