Skip to content

Commit 507b842

Browse files
committed
Drop fake time advancing in scoring tests
Now that we use explicit times passed to decay methods, there's no reason to make calls to `SinceEpoch::advance` in scoring tests.
1 parent aa8e1fb commit 507b842

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

lightning/src/routing/scoring.rs

-14
Original file line numberDiff line numberDiff line change
@@ -2145,7 +2145,6 @@ mod tests {
21452145
use super::{ChannelLiquidity, HistoricalBucketRangeTracker, ProbabilisticScoringFeeParameters, ProbabilisticScoringDecayParameters, ProbabilisticScorer};
21462146
use crate::blinded_path::{BlindedHop, BlindedPath};
21472147
use crate::util::config::UserConfig;
2148-
use crate::util::time::tests::SinceEpoch;
21492148

21502149
use crate::ln::channelmanager;
21512150
use crate::ln::msgs::{ChannelAnnouncement, ChannelUpdate, UnsignedChannelAnnouncement, UnsignedChannelUpdate};
@@ -2819,7 +2818,6 @@ mod tests {
28192818
assert_eq!(scorer.channel_penalty_msat(42, &source, &target, usage, &params), u64::max_value());
28202819

28212820
// Half decay (i.e., three-quarter life)
2822-
SinceEpoch::advance(Duration::from_secs(5));
28232821
scorer.decay_liquidity_certainty(Duration::from_secs(5));
28242822
let usage = ChannelUsage { amount_msat: 128, ..usage };
28252823
assert_eq!(scorer.channel_penalty_msat(42, &source, &target, usage, &params), 22);
@@ -2831,7 +2829,6 @@ mod tests {
28312829
assert_eq!(scorer.channel_penalty_msat(42, &source, &target, usage, &params), u64::max_value());
28322830

28332831
// One decay (i.e., half life)
2834-
SinceEpoch::advance(Duration::from_secs(5));
28352832
scorer.decay_liquidity_certainty(Duration::from_secs(10));
28362833
let usage = ChannelUsage { amount_msat: 64, ..usage };
28372834
assert_eq!(scorer.channel_penalty_msat(42, &source, &target, usage, &params), 0);
@@ -2843,7 +2840,6 @@ mod tests {
28432840
assert_eq!(scorer.channel_penalty_msat(42, &source, &target, usage, &params), u64::max_value());
28442841

28452842
// Fully decay liquidity lower bound.
2846-
SinceEpoch::advance(Duration::from_secs(10 * 7));
28472843
scorer.decay_liquidity_certainty(Duration::from_secs(10 * 8));
28482844
let usage = ChannelUsage { amount_msat: 0, ..usage };
28492845
assert_eq!(scorer.channel_penalty_msat(42, &source, &target, usage, &params), 0);
@@ -2855,14 +2851,12 @@ mod tests {
28552851
assert_eq!(scorer.channel_penalty_msat(42, &source, &target, usage, &params), u64::max_value());
28562852

28572853
// Fully decay liquidity upper bound.
2858-
SinceEpoch::advance(Duration::from_secs(10));
28592854
scorer.decay_liquidity_certainty(Duration::from_secs(10 * 9));
28602855
let usage = ChannelUsage { amount_msat: 0, ..usage };
28612856
assert_eq!(scorer.channel_penalty_msat(42, &source, &target, usage, &params), 0);
28622857
let usage = ChannelUsage { amount_msat: 1_024, ..usage };
28632858
assert_eq!(scorer.channel_penalty_msat(42, &source, &target, usage, &params), u64::max_value());
28642859

2865-
SinceEpoch::advance(Duration::from_secs(10));
28662860
scorer.decay_liquidity_certainty(Duration::from_secs(10 * 10));
28672861
let usage = ChannelUsage { amount_msat: 0, ..usage };
28682862
assert_eq!(scorer.channel_penalty_msat(42, &source, &target, usage, &params), 0);
@@ -2899,7 +2893,6 @@ mod tests {
28992893
assert_eq!(scorer.channel_penalty_msat(42, &source, &target, usage, &params), 281);
29002894

29012895
// Decaying knowledge gives less confidence (128, 896), meaning a higher penalty.
2902-
SinceEpoch::advance(Duration::from_secs(10));
29032896
scorer.decay_liquidity_certainty(Duration::from_secs(10));
29042897
assert_eq!(scorer.channel_penalty_msat(42, &source, &target, usage, &params), 291);
29052898

@@ -2914,7 +2907,6 @@ mod tests {
29142907
assert_eq!(scorer.channel_penalty_msat(42, &source, &target, usage, &params), 245);
29152908

29162909
// Further decaying affects the lower bound more than the upper bound (128, 928).
2917-
SinceEpoch::advance(Duration::from_secs(10));
29182910
scorer.decay_liquidity_certainty(Duration::from_secs(20));
29192911
assert_eq!(scorer.channel_penalty_msat(42, &source, &target, usage, &params), 280);
29202912
}
@@ -2944,7 +2936,6 @@ mod tests {
29442936
scorer.payment_path_failed(&payment_path_for_amount(500), 42, Duration::ZERO);
29452937
assert_eq!(scorer.channel_penalty_msat(42, &source, &target, usage, &params), u64::max_value());
29462938

2947-
SinceEpoch::advance(Duration::from_secs(10));
29482939
scorer.decay_liquidity_certainty(Duration::from_secs(10));
29492940
assert_eq!(scorer.channel_penalty_msat(42, &source, &target, usage, &params), 473);
29502941

@@ -2985,7 +2976,6 @@ mod tests {
29852976
assert_eq!(scorer.channel_penalty_msat(42, &source, &target, usage, &params), u64::max_value());
29862977

29872978
if decay_before_reload {
2988-
SinceEpoch::advance(Duration::from_secs(10));
29892979
scorer.decay_liquidity_certainty(Duration::from_secs(10));
29902980
}
29912981

@@ -2996,7 +2986,6 @@ mod tests {
29962986
let mut deserialized_scorer =
29972987
<ProbabilisticScorer<_, _>>::read(&mut serialized_scorer, (decay_params, &network_graph, &logger)).unwrap();
29982988
if !decay_before_reload {
2999-
SinceEpoch::advance(Duration::from_secs(10));
30002989
scorer.decay_liquidity_certainty(Duration::from_secs(10));
30012990
deserialized_scorer.decay_liquidity_certainty(Duration::from_secs(10));
30022991
}
@@ -3005,7 +2994,6 @@ mod tests {
30052994
scorer.payment_path_failed(&payment_path_for_amount(250), 43, Duration::from_secs(10));
30062995
assert_eq!(scorer.channel_penalty_msat(42, &source, &target, usage, &params), 300);
30072996

3008-
SinceEpoch::advance(Duration::from_secs(10));
30092997
deserialized_scorer.decay_liquidity_certainty(Duration::from_secs(20));
30102998
assert_eq!(deserialized_scorer.channel_penalty_msat(42, &source, &target, usage, &params), 370);
30112999
}
@@ -3278,7 +3266,6 @@ mod tests {
32783266

32793267
// Advance the time forward 16 half-lives (which the docs claim will ensure all data is
32803268
// gone), and check that we're back to where we started.
3281-
SinceEpoch::advance(Duration::from_secs(10 * 16));
32823269
scorer.decay_liquidity_certainty(Duration::from_secs(10 * 16));
32833270
assert_eq!(scorer.channel_penalty_msat(42, &source, &target, usage, &params), 168);
32843271
// Once fully decayed we still have data, so we get 0s for the buckets.
@@ -3304,7 +3291,6 @@ mod tests {
33043291
assert_eq!(scorer.channel_penalty_msat(42, &target, &source, usage, &params), 2048);
33053292

33063293
// Advance to decay all liquidity offsets to zero.
3307-
SinceEpoch::advance(Duration::from_secs(60 * 60 * 10));
33083294
scorer.decay_liquidity_certainty(Duration::from_secs(10 * (16 + 60 * 60)));
33093295

33103296
// Once even the bounds have decayed information about the channel should be removed

0 commit comments

Comments
 (0)