Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Fix: test corpus_inaccessible panic (#10019)
Browse files Browse the repository at this point in the history
If system uptime is less than the duration in the test, thread
will panic due to: 'overflow when subtracting duration from instant'.

Changed duration to 20 seconds to make it unlikely the test will
fail due to this condition.

Since no operations that carry a similar risk of panic occur outside
of the tests, it doesn't seem warranted to depend on an external crate
to fix this.
  • Loading branch information
mattrutherford authored and niklasad1 committed Dec 16, 2018
1 parent cf72f54 commit 1eaf664
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ethcore/light/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,15 @@ mod tests {

#[test]
fn corpus_inaccessible() {
let mut cache = Cache::new(Default::default(), Duration::from_secs(5 * 3600));
let duration = Duration::from_secs(20);
let mut cache = Cache::new(Default::default(), duration.clone());

cache.set_gas_price_corpus(vec![].into());
assert_eq!(cache.gas_price_corpus(), Some(vec![].into()));

{
let corpus_time = &mut cache.corpus.as_mut().unwrap().1;
*corpus_time = *corpus_time - Duration::from_secs(5 * 3600);
*corpus_time = *corpus_time - duration;
}
assert!(cache.gas_price_corpus().is_none());
}
Expand Down

0 comments on commit 1eaf664

Please sign in to comment.