From: Matt Corallo Date: Sun, 3 Apr 2022 20:36:09 +0000 (+0000) Subject: Add a test which demonstrates scores for some realistic payments X-Git-Tag: v0.0.107~65^2~2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=02bebee62e1a2becdc8ee71704c913e8bb367d02;p=rust-lightning Add a test which demonstrates scores for some realistic payments --- diff --git a/lightning/src/routing/scoring.rs b/lightning/src/routing/scoring.rs index b7aa996ce..d21d8fa3b 100644 --- a/lightning/src/routing/scoring.rs +++ b/lightning/src/routing/scoring.rs @@ -2119,6 +2119,29 @@ mod tests { assert_eq!(deserialized_scorer.channel_penalty_msat(42, 500, 1_000, &source, &target), 371); } + #[test] + fn scores_realistic_payments() { + // Shows the scores of "realistic" sends of 100k sats over channels of 1-10m sats (with a + // 50k sat reserve). + let network_graph = network_graph(); + let params = ProbabilisticScoringParameters::default(); + let scorer = ProbabilisticScorer::new(params, &network_graph); + let source = source_node_id(); + let target = target_node_id(); + + assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 950_000_000, &source, &target), 3645); + assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 1_950_000_000, &source, &target), 2512); + assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 2_950_000_000, &source, &target), 500); + assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 3_950_000_000, &source, &target), 1442); + assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 4_950_000_000, &source, &target), 500); + assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 5_950_000_000, &source, &target), 1820); + assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 6_950_000_000, &source, &target), 500); + assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 7_450_000_000, &source, &target), 500); + assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 7_950_000_000, &source, &target), 500); + assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 8_950_000_000, &source, &target), 500); + assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 9_950_000_000, &source, &target), 500); + } + #[test] fn adds_base_penalty_to_liquidity_penalty() { let network_graph = network_graph();