Skip to content

Commit

Permalink
test: make test case less timing sensisitive
Browse files Browse the repository at this point in the history
Test block_with_far_future_timestamp_is_invalid() would sometimes fail
when running tests in parallel because it depended on a sub-second
interval between when a value is set by the test-case and when it is
checked by Block::is_valid().

This commit makes the window 10 seconds, which hopefully should always
be enough.
  • Loading branch information
dan-da committed Feb 18, 2024
1 parent 4457990 commit 9b13d60
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/models/blockchain/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,8 @@ mod block_tests {
BFieldElement::new(future_time2.as_millis().try_into().unwrap());
assert!(block_1.is_valid(&genesis_block));

// Set block timestamp 2 hours in the future. (not valid)
let future_time3 = now + Duration::from_secs(60 * 60 * 2);
// Set block timestamp 2 hours + 10 secs in the future. (not valid)
let future_time3 = now + Duration::from_secs(60 * 60 * 2 + 10);
block_1.kernel.header.timestamp =
BFieldElement::new(future_time3.as_millis().try_into().unwrap());
assert!(!block_1.is_valid(&genesis_block));
Expand Down

0 comments on commit 9b13d60

Please sign in to comment.