mirror of
https://github.com/SagerNet/sing-box.git
synced 2026-04-14 04:38:28 +10:00
31 lines
758 B
Go
31 lines
758 B
Go
//go:build with_cloudflared
|
|
|
|
package cloudflare
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
)
|
|
|
|
func TestResolveDatagramVersionConfiguredWins(t *testing.T) {
|
|
version := resolveDatagramVersion(context.Background(), "account", "v3")
|
|
if version != "v3" {
|
|
t.Fatalf("expected configured version to win, got %s", version)
|
|
}
|
|
}
|
|
|
|
func TestResolveDatagramVersionRemoteSelection(t *testing.T) {
|
|
originalLookup := lookupCloudflaredFeatures
|
|
lookupCloudflaredFeatures = func(ctx context.Context) ([]byte, error) {
|
|
return []byte(`{"dv3_2":100}`), nil
|
|
}
|
|
defer func() {
|
|
lookupCloudflaredFeatures = originalLookup
|
|
}()
|
|
|
|
version := resolveDatagramVersion(context.Background(), "account", "")
|
|
if version != "v3" {
|
|
t.Fatalf("expected auto-selected v3, got %s", version)
|
|
}
|
|
}
|