Merge pull request #12742 from esengine/fix/objectcache-racy-windows

test(trustedstate): pin the clock and the file time in the racy-window test
This commit is contained in:
YHH authored and GitHub committed 2026-10-11 11:39:37 -07:00
commit 0807e52c2d
1 file changed
+8
@@ -100,6 +100,14 @@ func TestVerifyReadsBytesEvenWhenSizeAndTimeAreRestored(t *testing.T) {
func TestARecentlyWrittenObjectIsNotTrustedByItsTimestamp(t *testing.T) {
s, reads := countingStore(t)
d, _ := s.PutObject([]byte("payload"))
// The clock and the file's time are both pinned: a file system stamps from
// its own clock, which can lag the process clock by more than the window.
path, _ := s.objectPath(d)
mod := time.Now().Truncate(time.Second).Add(123 * time.Millisecond)
if err := os.Chtimes(path, mod, mod); err != nil {
t.Fatal(err)
}
s.now = func() time.Time { return mod.Add(time.Millisecond) }
for range 3 {
if _, err := s.Object(d); err != nil {
t.Fatal(err)