ipn/ipnlocal: fix racy tests (round 2)

Change-Id: Idef2a891b37f9dc76e86eb425cc0fc8abec31a45
This commit is contained in:
M. J. Fromberger 2025-09-18 10:16:30 -07:00
parent b846167f0d
commit 8c89e75c50

View File

@ -2367,19 +2367,20 @@ func TestObserveDNSResponse(t *testing.T) {
} }
rc := &appctest.RouteCollector{} rc := &appctest.RouteCollector{}
b.appConnector = appc.NewAppConnector(appc.Config{ a := appc.NewAppConnector(appc.Config{
Logf: t.Logf, Logf: t.Logf,
EventBus: bus, EventBus: bus,
RouteAdvertiser: rc, RouteAdvertiser: rc,
HasStoredRoutes: shouldStore, HasStoredRoutes: shouldStore,
}) })
b.appConnector.UpdateDomains([]string{"example.com"}) a.UpdateDomains([]string{"example.com"})
b.appConnector.Wait(context.Background()) a.Wait(t.Context())
b.appConnector = a
if err := b.ObserveDNSResponse(dnsResponse("example.com.", "192.0.0.8")); err != nil { if err := b.ObserveDNSResponse(dnsResponse("example.com.", "192.0.0.8")); err != nil {
t.Errorf("ObserveDNSResponse: %v", err) t.Errorf("ObserveDNSResponse: %v", err)
} }
b.appConnector.Wait(context.Background()) a.Wait(t.Context())
wantRoutes := []netip.Prefix{netip.MustParsePrefix("192.0.0.8/32")} wantRoutes := []netip.Prefix{netip.MustParsePrefix("192.0.0.8/32")}
if !slices.Equal(rc.Routes(), wantRoutes) { if !slices.Equal(rc.Routes(), wantRoutes) {
t.Fatalf("got routes %v, want %v", rc.Routes(), wantRoutes) t.Fatalf("got routes %v, want %v", rc.Routes(), wantRoutes)