@@ -2151,7 +2151,6 @@ mod tests {
2151
2151
use super :: { ChannelLiquidity , HistoricalBucketRangeTracker , ProbabilisticScoringFeeParameters , ProbabilisticScoringDecayParameters , ProbabilisticScorer } ;
2152
2152
use crate :: blinded_path:: { BlindedHop , BlindedPath } ;
2153
2153
use crate :: util:: config:: UserConfig ;
2154
- use crate :: util:: time:: tests:: SinceEpoch ;
2155
2154
2156
2155
use crate :: ln:: channelmanager;
2157
2156
use crate :: ln:: msgs:: { ChannelAnnouncement , ChannelUpdate , UnsignedChannelAnnouncement , UnsignedChannelUpdate } ;
@@ -2901,7 +2900,6 @@ mod tests {
2901
2900
assert_eq ! ( scorer. channel_penalty_msat( & candidate, usage, & params) , u64 :: max_value( ) ) ;
2902
2901
2903
2902
// Half decay (i.e., three-quarter life)
2904
- SinceEpoch :: advance ( Duration :: from_secs ( 5 ) ) ;
2905
2903
scorer. time_passed ( Duration :: from_secs ( 5 ) ) ;
2906
2904
let usage = ChannelUsage { amount_msat : 128 , ..usage } ;
2907
2905
assert_eq ! ( scorer. channel_penalty_msat( & candidate, usage, & params) , 22 ) ;
@@ -2913,7 +2911,6 @@ mod tests {
2913
2911
assert_eq ! ( scorer. channel_penalty_msat( & candidate, usage, & params) , u64 :: max_value( ) ) ;
2914
2912
2915
2913
// One decay (i.e., half life)
2916
- SinceEpoch :: advance ( Duration :: from_secs ( 5 ) ) ;
2917
2914
scorer. time_passed ( Duration :: from_secs ( 10 ) ) ;
2918
2915
let usage = ChannelUsage { amount_msat : 64 , ..usage } ;
2919
2916
assert_eq ! ( scorer. channel_penalty_msat( & candidate, usage, & params) , 0 ) ;
@@ -2925,7 +2922,6 @@ mod tests {
2925
2922
assert_eq ! ( scorer. channel_penalty_msat( & candidate, usage, & params) , u64 :: max_value( ) ) ;
2926
2923
2927
2924
// Fully decay liquidity lower bound.
2928
- SinceEpoch :: advance ( Duration :: from_secs ( 10 * 7 ) ) ;
2929
2925
scorer. time_passed ( Duration :: from_secs ( 10 * 8 ) ) ;
2930
2926
let usage = ChannelUsage { amount_msat : 0 , ..usage } ;
2931
2927
assert_eq ! ( scorer. channel_penalty_msat( & candidate, usage, & params) , 0 ) ;
@@ -2937,14 +2933,12 @@ mod tests {
2937
2933
assert_eq ! ( scorer. channel_penalty_msat( & candidate, usage, & params) , u64 :: max_value( ) ) ;
2938
2934
2939
2935
// Fully decay liquidity upper bound.
2940
- SinceEpoch :: advance ( Duration :: from_secs ( 10 ) ) ;
2941
2936
scorer. time_passed ( Duration :: from_secs ( 10 * 9 ) ) ;
2942
2937
let usage = ChannelUsage { amount_msat : 0 , ..usage } ;
2943
2938
assert_eq ! ( scorer. channel_penalty_msat( & candidate, usage, & params) , 0 ) ;
2944
2939
let usage = ChannelUsage { amount_msat : 1_024 , ..usage } ;
2945
2940
assert_eq ! ( scorer. channel_penalty_msat( & candidate, usage, & params) , u64 :: max_value( ) ) ;
2946
2941
2947
- SinceEpoch :: advance ( Duration :: from_secs ( 10 ) ) ;
2948
2942
scorer. time_passed ( Duration :: from_secs ( 10 * 10 ) ) ;
2949
2943
let usage = ChannelUsage { amount_msat : 0 , ..usage } ;
2950
2944
assert_eq ! ( scorer. channel_penalty_msat( & candidate, usage, & params) , 0 ) ;
@@ -2986,7 +2980,6 @@ mod tests {
2986
2980
assert_eq ! ( scorer. channel_penalty_msat( & candidate, usage, & params) , 281 ) ;
2987
2981
2988
2982
// Decaying knowledge gives less confidence (128, 896), meaning a higher penalty.
2989
- SinceEpoch :: advance ( Duration :: from_secs ( 10 ) ) ;
2990
2983
scorer. time_passed ( Duration :: from_secs ( 10 ) ) ;
2991
2984
assert_eq ! ( scorer. channel_penalty_msat( & candidate, usage, & params) , 291 ) ;
2992
2985
@@ -3001,7 +2994,6 @@ mod tests {
3001
2994
assert_eq ! ( scorer. channel_penalty_msat( & candidate, usage, & params) , 245 ) ;
3002
2995
3003
2996
// Further decaying affects the lower bound more than the upper bound (128, 928).
3004
- SinceEpoch :: advance ( Duration :: from_secs ( 10 ) ) ;
3005
2997
scorer. time_passed ( Duration :: from_secs ( 20 ) ) ;
3006
2998
assert_eq ! ( scorer. channel_penalty_msat( & candidate, usage, & params) , 280 ) ;
3007
2999
}
@@ -3036,7 +3028,6 @@ mod tests {
3036
3028
} ;
3037
3029
assert_eq ! ( scorer. channel_penalty_msat( & candidate, usage, & params) , u64 :: max_value( ) ) ;
3038
3030
3039
- SinceEpoch :: advance ( Duration :: from_secs ( 10 ) ) ;
3040
3031
scorer. time_passed ( Duration :: from_secs ( 10 ) ) ;
3041
3032
assert_eq ! ( scorer. channel_penalty_msat( & candidate, usage, & params) , 473 ) ;
3042
3033
@@ -3082,7 +3073,6 @@ mod tests {
3082
3073
assert_eq ! ( scorer. channel_penalty_msat( & candidate, usage, & params) , u64 :: max_value( ) ) ;
3083
3074
3084
3075
if decay_before_reload {
3085
- SinceEpoch :: advance ( Duration :: from_secs ( 10 ) ) ;
3086
3076
scorer. time_passed ( Duration :: from_secs ( 10 ) ) ;
3087
3077
}
3088
3078
@@ -3093,7 +3083,6 @@ mod tests {
3093
3083
let mut deserialized_scorer =
3094
3084
<ProbabilisticScorer < _ , _ > >:: read ( & mut serialized_scorer, ( decay_params, & network_graph, & logger) ) . unwrap ( ) ;
3095
3085
if !decay_before_reload {
3096
- SinceEpoch :: advance ( Duration :: from_secs ( 10 ) ) ;
3097
3086
scorer. time_passed ( Duration :: from_secs ( 10 ) ) ;
3098
3087
deserialized_scorer. time_passed ( Duration :: from_secs ( 10 ) ) ;
3099
3088
}
@@ -3102,7 +3091,6 @@ mod tests {
3102
3091
scorer. payment_path_failed ( & payment_path_for_amount ( 250 ) , 43 , Duration :: from_secs ( 10 ) ) ;
3103
3092
assert_eq ! ( scorer. channel_penalty_msat( & candidate, usage, & params) , 300 ) ;
3104
3093
3105
- SinceEpoch :: advance ( Duration :: from_secs ( 10 ) ) ;
3106
3094
deserialized_scorer. time_passed ( Duration :: from_secs ( 20 ) ) ;
3107
3095
assert_eq ! ( deserialized_scorer. channel_penalty_msat( & candidate, usage, & params) , 370 ) ;
3108
3096
}
@@ -3436,7 +3424,6 @@ mod tests {
3436
3424
3437
3425
// Advance the time forward 16 half-lives (which the docs claim will ensure all data is
3438
3426
// gone), and check that we're back to where we started.
3439
- SinceEpoch :: advance ( Duration :: from_secs ( 10 * 16 ) ) ;
3440
3427
scorer. time_passed ( Duration :: from_secs ( 10 * 16 ) ) ;
3441
3428
{
3442
3429
let network_graph = network_graph. read_only ( ) ;
@@ -3481,7 +3468,6 @@ mod tests {
3481
3468
}
3482
3469
3483
3470
// Advance to decay all liquidity offsets to zero.
3484
- SinceEpoch :: advance ( Duration :: from_secs ( 60 * 60 * 10 ) ) ;
3485
3471
scorer. time_passed ( Duration :: from_secs ( 10 * ( 16 + 60 * 60 ) ) ) ;
3486
3472
3487
3473
// Once even the bounds have decayed information about the channel should be removed
@@ -3734,10 +3720,10 @@ pub mod benches {
3734
3720
}
3735
3721
let mut cur_time = Duration :: ZERO ;
3736
3722
cur_time += Duration :: from_millis ( 1 ) ;
3737
- scorer. decay_liquidity_certainty ( cur_time) ;
3723
+ scorer. time_passed ( cur_time) ;
3738
3724
bench. bench_function ( "decay_100k_channel_bounds" , |b| b. iter ( || {
3739
3725
cur_time += Duration :: from_millis ( 1 ) ;
3740
- scorer. decay_liquidity_certainty ( cur_time) ;
3726
+ scorer. time_passed ( cur_time) ;
3741
3727
} ) ) ;
3742
3728
}
3743
3729
}
0 commit comments