Skip to content

Commit 02bebee

Browse files
committed
Add a test which demonstrates scores for some realistic payments
1 parent 0a0f87c commit 02bebee

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

lightning/src/routing/scoring.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,6 +2119,29 @@ mod tests {
21192119
assert_eq!(deserialized_scorer.channel_penalty_msat(42, 500, 1_000, &source, &target), 371);
21202120
}
21212121

2122+
#[test]
2123+
fn scores_realistic_payments() {
2124+
// Shows the scores of "realistic" sends of 100k sats over channels of 1-10m sats (with a
2125+
// 50k sat reserve).
2126+
let network_graph = network_graph();
2127+
let params = ProbabilisticScoringParameters::default();
2128+
let scorer = ProbabilisticScorer::new(params, &network_graph);
2129+
let source = source_node_id();
2130+
let target = target_node_id();
2131+
2132+
assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 950_000_000, &source, &target), 3645);
2133+
assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 1_950_000_000, &source, &target), 2512);
2134+
assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 2_950_000_000, &source, &target), 500);
2135+
assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 3_950_000_000, &source, &target), 1442);
2136+
assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 4_950_000_000, &source, &target), 500);
2137+
assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 5_950_000_000, &source, &target), 1820);
2138+
assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 6_950_000_000, &source, &target), 500);
2139+
assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 7_450_000_000, &source, &target), 500);
2140+
assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 7_950_000_000, &source, &target), 500);
2141+
assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 8_950_000_000, &source, &target), 500);
2142+
assert_eq!(scorer.channel_penalty_msat(42, 100_000_000, 9_950_000_000, &source, &target), 500);
2143+
}
2144+
21222145
#[test]
21232146
fn adds_base_penalty_to_liquidity_penalty() {
21242147
let network_graph = network_graph();

0 commit comments

Comments
 (0)