package wgtunnel import ( "context" "testing" ) // R-1247: the line test's server is the desired block's pbs_tunnel_ip, and ONLY while the tunnel is operational // (registered + unit active) — „no tunnel → no test" rests on this answer. func TestLineTestTargetOnlyWhileOperational(t *testing.T) { m, _, active, _ := testManager(t, &fakeHub{}) ctx := context.Background() if _, ok := m.LineTestTarget(); ok { t.Fatal("a target before any Apply") } m.Apply(ctx, false, nil) // registers pub := localPub(t, m) m.Apply(ctx, true, testBlock(pub)) // installs; the unit is not active yet if _, ok := m.LineTestTarget(); ok { t.Fatal("a target while the unit is not active") } *active = true m.Apply(ctx, true, testBlock(pub)) ip, ok := m.LineTestTarget() if !ok || ip.String() != "10.77.0.1" { t.Fatalf("operational tunnel: target %v ok=%v, want 10.77.0.1", ip, ok) } m.Apply(ctx, true, nil) // revoked if _, ok := m.LineTestTarget(); ok { t.Fatal("a target after the hub revoked the tunnel") } }