Release 3.8.2.3: cheaper poll I/O, batched macOS sysproxy, no Connect Clone.
Trust corebin cache without Stat; batch networksetup; ActiveProxyURI instead of Config.Clone. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestResolveCacheAndStale(t *testing.T) {
|
||||
func TestResolveTrustsCacheWithoutStat(t *testing.T) {
|
||||
Invalidate()
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "core")
|
||||
@@ -20,26 +20,40 @@ func TestResolveCacheAndStale(t *testing.T) {
|
||||
return path, nil
|
||||
}
|
||||
if p, err := Resolve(key, fn); err != nil || p != path || calls != 1 {
|
||||
t.Fatalf("first: path=%q calls=%d err=%v", p, calls, err)
|
||||
t.Fatalf("first: %q %v calls=%d", p, err, calls)
|
||||
}
|
||||
_ = os.Remove(path) // missing on disk — cache still trusted until Invalidate
|
||||
if p, err := Resolve(key, fn); err != nil || p != path || calls != 1 {
|
||||
t.Fatalf("cached: path=%q calls=%d err=%v", p, calls, err)
|
||||
t.Fatalf("cached without Stat: %q %v calls=%d", p, err, calls)
|
||||
}
|
||||
_ = os.Remove(path)
|
||||
if _, err := Resolve(key, fn); err != nil {
|
||||
// fn returns removed path; Resolve still succeeds but next Stat misses
|
||||
t.Fatalf("unexpected err after delete before recreate: %v", err)
|
||||
Invalidate()
|
||||
if _, err := Resolve(key, fn); err == nil && calls != 2 {
|
||||
// fn returns deleted path; Resolve still succeeds
|
||||
}
|
||||
if calls != 2 {
|
||||
t.Fatalf("expected refresh call, got %d", calls)
|
||||
t.Fatalf("after Invalidate expected refresh, calls=%d", calls)
|
||||
}
|
||||
if err := os.WriteFile(path, []byte("y"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
func TestVirtualEmbeddedAWG(t *testing.T) {
|
||||
Invalidate()
|
||||
key := CacheKey("/bin", "awg")
|
||||
calls := 0
|
||||
p, err := Resolve(key, func() (string, error) {
|
||||
calls++
|
||||
return "embedded-amneziawg-go", nil
|
||||
})
|
||||
if err != nil || p != "embedded-amneziawg-go" || calls != 1 {
|
||||
t.Fatalf("%q %v calls=%d", p, err, calls)
|
||||
}
|
||||
if p, err := Resolve(key, fn); err != nil || p != path {
|
||||
t.Fatalf("after recreate: %q %v", p, err)
|
||||
if !VirtualPath(p) {
|
||||
t.Fatal("expected virtual")
|
||||
}
|
||||
if ProtoKey("vless") != "xray" || ProtoKey("naive") != "naive" {
|
||||
t.Fatal("ProtoKey")
|
||||
p2, err := Resolve(key, func() (string, error) {
|
||||
calls++
|
||||
return "embedded-amneziawg-go", nil
|
||||
})
|
||||
if err != nil || p2 != p || calls != 1 {
|
||||
t.Fatalf("second: %q calls=%d", p2, calls)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user