рабочий вариант, но скороть 10 МБит
This commit is contained in:
@@ -3,7 +3,6 @@ package mesh
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -90,7 +89,7 @@ func TestPeerConnectionManagerRecordsFailureAndSuppressesActiveBackoff(t *testin
|
||||
cache := NewPeerCache(PeerCacheConfig{
|
||||
Local: local,
|
||||
PeerEndpoints: map[string]string{
|
||||
"node-b": "http://127.0.0.1:1",
|
||||
"node-b": "quic://127.0.0.1:1",
|
||||
},
|
||||
WarmPeerLimit: 1,
|
||||
Now: now,
|
||||
@@ -100,7 +99,6 @@ func TestPeerConnectionManagerRecordsFailureAndSuppressesActiveBackoff(t *testin
|
||||
Local: local,
|
||||
PeerCache: cache,
|
||||
Tracker: tracker,
|
||||
HTTPClient: &http.Client{Timeout: 20 * time.Millisecond},
|
||||
ProbeTimeout: 20 * time.Millisecond,
|
||||
Now: func() time.Time {
|
||||
current = current.Add(10 * time.Millisecond)
|
||||
@@ -121,7 +119,7 @@ func TestPeerConnectionManagerRecordsFailureAndSuppressesActiveBackoff(t *testin
|
||||
}
|
||||
}
|
||||
|
||||
func TestPeerConnectionManagerProbesRelayControlLease(t *testing.T) {
|
||||
func TestPeerConnectionManagerProbesRelayQUICLease(t *testing.T) {
|
||||
now := time.Date(2026, 4, 28, 12, 0, 0, 0, time.UTC)
|
||||
current := now
|
||||
tlsConfig := testQUICTLSConfig(t)
|
||||
@@ -188,7 +186,7 @@ func TestPeerConnectionManagerProbesRelayControlLease(t *testing.T) {
|
||||
if cycle.Attempted != 1 ||
|
||||
cycle.Succeeded != 1 ||
|
||||
cycle.Deferred != 0 ||
|
||||
cycle.RelayControlCount != 1 ||
|
||||
cycle.RelayQUICCount != 1 ||
|
||||
cycle.RendezvousResolvedCount != 1 ||
|
||||
cycle.RendezvousRequiredCount != 0 {
|
||||
t.Fatalf("unexpected relay-control cycle: %+v", cycle)
|
||||
@@ -227,11 +225,11 @@ func TestPeerConnectionProbeTargetsFallsBackToBestPeerCertSHA256(t *testing.T) {
|
||||
BestPeerCertSHA256: "intent-cert",
|
||||
}
|
||||
cacheEntry := PeerCacheEntry{
|
||||
NodeID: "node-b",
|
||||
BestPeerCertSHA256: "cache-cert",
|
||||
BestCandidateID: "node-b-best",
|
||||
BestTransport: "direct_quic",
|
||||
Endpoint: "quic://94.141.118.222:19199",
|
||||
NodeID: "node-b",
|
||||
BestPeerCertSHA256: "cache-cert",
|
||||
BestCandidateID: "node-b-best",
|
||||
BestTransport: "direct_quic",
|
||||
Endpoint: "quic://94.141.118.222:19199",
|
||||
EndpointCandidates: []PeerEndpointCandidate{
|
||||
{
|
||||
EndpointID: "node-b-public",
|
||||
@@ -259,6 +257,49 @@ func TestPeerConnectionProbeTargetsFallsBackToBestPeerCertSHA256(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPeerConnectionProbeTargetsUsesRelayLeaseCertForRelayEndpoint(t *testing.T) {
|
||||
intent := PeerConnectionIntent{
|
||||
NodeID: "node-b",
|
||||
BestCandidateID: "lease-node-b-via-node-r",
|
||||
Endpoint: "quic://195.123.240.88:19131",
|
||||
Transport: "relay_quic",
|
||||
BestPeerCertSHA256: "relay-cert",
|
||||
RelayCandidate: true,
|
||||
ConnectionState: PeerConnectionBackoff,
|
||||
}
|
||||
cacheEntry := PeerCacheEntry{
|
||||
NodeID: "node-b",
|
||||
BestPeerCertSHA256: "direct-cert",
|
||||
EndpointCandidates: []PeerEndpointCandidate{
|
||||
{
|
||||
EndpointID: "node-b-private",
|
||||
NodeID: "node-b",
|
||||
Transport: "direct_quic",
|
||||
Address: "quic://192.168.200.61:19132",
|
||||
Reachability: "private",
|
||||
ConnectivityMode: "private_lan",
|
||||
Priority: 1,
|
||||
Metadata: peerConnectionProbeMetadata(t, "direct-cert"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
targets := peerConnectionProbeTargets(intent, cacheEntry)
|
||||
if len(targets) != 2 {
|
||||
t.Fatalf("target count = %d, want 2", len(targets))
|
||||
}
|
||||
for _, target := range targets {
|
||||
if target.Endpoint != "quic://195.123.240.88:19131" {
|
||||
continue
|
||||
}
|
||||
if target.PeerCertSHA256 != "relay-cert" {
|
||||
t.Fatalf("relay endpoint cert = %q, want relay-cert", target.PeerCertSHA256)
|
||||
}
|
||||
return
|
||||
}
|
||||
t.Fatalf("relay endpoint target not found: %+v", targets)
|
||||
}
|
||||
|
||||
func TestPeerConnectionProbeTargetsUpgradeRelayReadyPeerToDirectQUIC(t *testing.T) {
|
||||
now := time.Date(2026, 5, 18, 12, 0, 0, 0, time.UTC)
|
||||
current := now
|
||||
|
||||
Reference in New Issue
Block a user