Commit 8e3f2ba
authored
fix(sync): use microseconds for MAX_TIMESTAMP_FUTURE_SHIFT (#99)
## Description
Fixes future timestamp validation so the allowed skew matches the
documented ten-minute policy.
Entry timestamps and `system_time_now()` are Unix epoch microseconds.
`MAX_TIMESTAMP_FUTURE_SHIFT` was derived using milliseconds, so the
effective cap was about 600 ms instead of ten minutes. The constant now
uses `Duration::from_secs(1).as_micros()` so it is expressed in the same
unit as wall time.
Adds `test_future_timestamp_accepts_one_second_skew`, a regression test
that would fail if the slack constant were still on millisecond scale:
it inserts an entry one second in the future, then asserts the stored
entry matches (round-trip), not only that insert succeeds.
## Breaking Changes
None
## Notes & open questions
- Closes #97
- Considered introducing a UnixEpochMicros newtype and threading it
through the public API so unit mix-ups are harder to repeat, but that
would be a breaking change with little extra correctness beyond fixing
the constant, so this PR only corrects the scale of
MAX_TIMESTAMP_FUTURE_SHIFT and adds a regression test.
## Change checklist
- [x] Self-review.
- [ ] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All breaking changes documented.1 parent b4f985d commit 8e3f2ba
1 file changed
Lines changed: 27 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
1785 | 1785 | | |
1786 | 1786 | | |
1787 | 1787 | | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
1788 | 1814 | | |
1789 | 1815 | | |
1790 | 1816 | | |
| |||
0 commit comments