We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
MonotonicTime::elapsed()
1 parent 4507d6f commit b138ea2Copy full SHA for b138ea2
lightning/src/util/time.rs
@@ -89,7 +89,7 @@ impl Time for MonotonicTime {
89
}
90
91
fn elapsed(&self) -> Duration {
92
- self.0.elapsed()
+ Self::now().0 - self.0
93
94
95
@@ -180,7 +180,10 @@ pub mod tests {
180
#[cfg(not(feature = "no-std"))]
181
fn monotonic_time_go_backward() {
182
let now = super::MonotonicTime::now();
183
+ assert!(now.elapsed() < Duration::from_secs(10));
184
+
185
let ten_years = Duration::from_secs(10 * 365 * 24 * 60 * 60);
- let _past = now - ten_years;
186
+ let past = now - ten_years;
187
+ assert!(past.elapsed() >= ten_years);
188
189
0 commit comments