Skip to content

Commit

Permalink
f drop shift test
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Dec 6, 2023
1 parent b607543 commit 05c13b2
Showing 1 changed file with 0 additions and 41 deletions.
41 changes: 0 additions & 41 deletions lightning/src/routing/scoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2952,47 +2952,6 @@ mod tests {
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), u64::max_value());
}

#[test]
fn decays_liquidity_bounds_without_shift_overflow() {
let logger = TestLogger::new();
let network_graph = network_graph(&logger);
let params = ProbabilisticScoringFeeParameters {
liquidity_penalty_multiplier_msat: 1_000,
..ProbabilisticScoringFeeParameters::zero_penalty()
};
let decay_params = ProbabilisticScoringDecayParameters {
liquidity_offset_half_life: Duration::from_secs(10),
..ProbabilisticScoringDecayParameters::default()
};
let mut scorer = ProbabilisticScorer::new(decay_params, &network_graph, &logger);
let source = source_node_id();
let usage = ChannelUsage {
amount_msat: 256,
inflight_htlc_msat: 0,
effective_capacity: EffectiveCapacity::Total { capacity_msat: 1_024, htlc_maximum_msat: 1_000 },
};
let channel = network_graph.read_only().channel(42).unwrap().to_owned();
let (info, _) = channel.as_directed_from(&source).unwrap();
let candidate = CandidateRouteHop::PublicHop {
info,
short_channel_id: 42,
};
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 125);

scorer.payment_path_failed(&payment_path_for_amount(512), 42, Duration::ZERO);
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 281);

// An unchecked right shift 64 bits or more in DirectedChannelLiquidity::decayed_offset_msat
// would cause an overflow.
SinceEpoch::advance(Duration::from_secs(10 * 64));
scorer.decay_liquidity_certainty(Duration::from_secs(10 * 64));
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 125);

SinceEpoch::advance(Duration::from_secs(10));
scorer.decay_liquidity_certainty(Duration::from_secs(10 * 65));
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 125);
}

#[test]
fn restricts_liquidity_bounds_after_decay() {
let logger = TestLogger::new();
Expand Down

0 comments on commit 05c13b2

Please sign in to comment.