From 221890a1445d5a1a376242b61a2dc0a067aa2c94 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 28 Oct 2026 22:00:35 +0000 Subject: [PATCH] Stop package_delay_hides_then_reveals flaking on its 1-second delay The test gave its proxy a 1-second package delay and expected the listing and the direct download to both fall inside it. On CI's `test` job, which runs test binaries side by side, the second passed between the two calls, and the download answered 200 where the test wanted 404 (forgepkg/forge#604). The delay is now an hour, which no runner takes between two calls, and the window elapses by backdating the version's `first_seen_at` two hours instead of sleeping past it, as the e2e test of the same name already does. The test no longer reads the wall clock and no longer sleeps. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012e6DJaQwXDu83fu8xUmtAc --- crates/core/tests/proxy_read.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/crates/core/tests/proxy_read.rs b/crates/core/tests/proxy_read.rs index 5c50d3da..68bea35c 100644 --- a/crates/core/tests/proxy_read.rs +++ b/crates/core/tests/proxy_read.rs @@ -713,8 +713,10 @@ async fn package_delay_hides_then_reveals() { corpus.insert("sample.lib".to_string(), vers); let mock = start_mock(corpus).await; - // 1-second delay window. - let repo = make_proxy(&pool, &format!("{}/index.json", mock.base), 1, true).await; + // A one-hour delay window, which no runner is slow enough to pass between + // two calls: a 1-second one passed between the listing and the download + // on CI's loaded `test` job (#604). + let repo = make_proxy(&pool, &format!("{}/index.json", mock.base), 3600, true).await; let px = proxy_repo(&pool, cas, cache); // Inside the window: hidden from enumeration, 404 on direct download. @@ -748,8 +750,16 @@ async fn package_delay_hides_then_reveals() { "delay-gated 404 must never set the negative cache" ); - // After the window elapses, it becomes visible and downloadable. - tokio::time::sleep(std::time::Duration::from_millis(1100)).await; + // After the window elapses, it becomes visible and downloadable. The + // window elapses without a sleep: the version was first seen two hours ago. + sqlx::query( + "UPDATE proxy_cached_version SET first_seen_at = now() - interval '2 hours' \ + WHERE repository_id = $1", + ) + .bind(repo_id(&pool, &repo).await) + .execute(&pool) + .await + .unwrap(); let versions = px.list_versions(&repo, "Sample.Lib").await.unwrap(); assert_eq!( versions.len(),