Fix: test corpus_inaccessible panic (#10019)
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.
This commit is contained in:
parent
349098e7b2
commit
2e0246a6c2
@ -179,14 +179,15 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn corpus_inaccessible() {
|
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());
|
cache.set_gas_price_corpus(vec![].into());
|
||||||
assert_eq!(cache.gas_price_corpus(), Some(vec![].into()));
|
assert_eq!(cache.gas_price_corpus(), Some(vec![].into()));
|
||||||
|
|
||||||
{
|
{
|
||||||
let corpus_time = &mut cache.corpus.as_mut().unwrap().1;
|
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());
|
assert!(cache.gas_price_corpus().is_none());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user