From 8cb8ab9aedd39525d839abd6ab3ce924ba35bf86 Mon Sep 17 00:00:00 2001 From: tonywangcn Date: Thu, 29 Oct 2026 22:12:31 +0800 Subject: [PATCH] Fix Go toolchain and probe accounting test Use the patched Go release in module metadata and the pinned builder image. Delay the local echo response so the asynchronous request write is counted before the test inspects traffic totals. --- AGENTS.md | 2 +- Dockerfile | 2 +- go.mod | 2 +- internal/probe/tester_test.go | 3 +++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 1b7b7b6..ca385a1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,7 +4,7 @@ Rules for anyone, human or automated, changing this repository. ## Build and test -- Go 1.27.2 or newer (see `go.mod`). +- Go 1.27.3 or newer (see `go.mod`). - `make check` runs `gofmt` verification, `go vet`, `go test ./...` and `go test -race ./...`. CI also runs `staticcheck` and `govulncheck`. - Tests are hermetic: they use an in-memory Redis and synthetic GeoIP data and diff --git a/Dockerfile b/Dockerfile index 26e6c8e..76e58b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # Base images are pinned by multi-arch index digest; keep the tag for # readability and bump tag and digest together # (`docker buildx imagetools inspect `). -FROM golang:1.27.2-alpine@sha256:f92b6ef800e499660581efdabdf25d9d817a9d124eaf900924f0504e7e27e12d AS build +FROM golang:1.27.3-alpine@sha256:d200d2dd76b03a99b52651fd1325aff7dcd35422c35c01bac56571b0507f3deb AS build # Optional module-proxy override for restricted networks: # docker build --build-arg GOPROXY=https://goproxy.cn,direct . diff --git a/go.mod b/go.mod index af8cfad..735def7 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/Crawlora-org/FreeProxyAPI -go 1.27.2 +go 1.27.3 require ( github.com/alicebob/miniredis/v2 v2.40.0 diff --git a/internal/probe/tester_test.go b/internal/probe/tester_test.go index 9461039..017dd46 100644 --- a/internal/probe/tester_test.go +++ b/internal/probe/tester_test.go @@ -117,6 +117,9 @@ func TestRunProbeEchoThroughHTTPProxy(t *testing.T) { requests := 0 var seenNonce string server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // The transport writes request bytes asynchronously. Keep the response + // behind that write so the traffic counter has a deterministic snapshot. + time.Sleep(10 * time.Millisecond) requests++ seenNonce = r.URL.Query().Get(EchoNonceParam) w.Header().Set("Content-Type", "application/json")