(t *testing.T)
| 44 | var logger = slog.Default() |
| 45 | |
| 46 | func TestWatchPostUpdateWithLocalRoute(t *testing.T) { |
| 47 | s := NewBgpServer() |
| 48 | go s.Serve() |
| 49 | err := s.StartBgp(context.Background(), &api.StartBgpRequest{ |
| 50 | Global: &api.Global{ |
| 51 | Asn: 1, |
| 52 | RouterId: "1.1.1.1", |
| 53 | ListenPort: -1, |
| 54 | }, |
| 55 | }) |
| 56 | require.NoError(t, err) |
| 57 | defer s.StopBgp(context.Background(), &api.StopBgpRequest{}) |
| 58 | |
| 59 | // Add local path (no PeerInfo) |
| 60 | panh, _ := bgp.NewPathAttributeNextHop(netip.MustParseAddr("10.0.0.1")) |
| 61 | attrs := []bgp.PathAttributeInterface{ |
| 62 | bgp.NewPathAttributeOrigin(0), |
| 63 | panh, |
| 64 | } |
| 65 | nlri, _ := bgp.NewIPAddrPrefix(netip.MustParsePrefix("10.10.0.0/24")) |
| 66 | path, _ := apiutil.NewPath(bgp.RF_IPv4_UC, nlri, false, attrs, time.Now()) |
| 67 | |
| 68 | _, err = s.AddPath(apiutil.AddPathRequest{Paths: []*apiutil.Path{mustApi2apiutilPath(path)}}) |
| 69 | require.NoError(t, err) |
| 70 | |
| 71 | // Calling watch with initPostUpdate=true and a peerAddress filter. |
| 72 | // This will traverse the global RIB, encounter the local path with no PeerInfo, |
| 73 | // and apply the postUpdateFilter. It should not panic. |
| 74 | s.watch(WatchPostUpdate(true, "10.2.2.2", "")) |
| 75 | } |
| 76 | |
| 77 | func TestStop(t *testing.T) { |
| 78 | assert := assert.New(t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…