(t *testing.T)
| 143 | var testNextHop = netip.MustParseAddr("10.3.1.1") |
| 144 | |
| 145 | func TestApplyToPathList_UnreachableNoMED(t *testing.T) { |
| 146 | // Simulates the zebra-nht scenario: a path with no MED and an |
| 147 | // unreachable nexthop should get IsNexthopInvalid=true. |
| 148 | assert := assert.New(t) |
| 149 | |
| 150 | nlri, _ := bgp.NewIPAddrPrefix(netip.MustParsePrefix("10.3.2.0/24")) |
| 151 | nh, _ := bgp.NewPathAttributeNextHop(testNextHop) |
| 152 | attrs := []bgp.PathAttributeInterface{ |
| 153 | bgp.NewPathAttributeOrigin(bgp.BGP_ORIGIN_ATTR_TYPE_INCOMPLETE), |
| 154 | nh, |
| 155 | } |
| 156 | path := table.NewPath(bgp.RF_IPv4_UC, nil, bgp.PathNLRI{NLRI: nlri}, false, attrs, time.Now(), false) |
| 157 | |
| 158 | cache := nexthopStateCache{ |
| 159 | testNextHop: math.MaxUint32, // unreachable |
| 160 | } |
| 161 | |
| 162 | updated := cache.applyToPathList([]*table.Path{path}) |
| 163 | assert.Len(updated, 1) |
| 164 | assert.True(updated[0].IsNexthopInvalid) |
| 165 | assert.False(updated[0].IsWithdraw) |
| 166 | |
| 167 | // Applying again should produce no updates (idempotent) |
| 168 | updated2 := cache.applyToPathList(updated) |
| 169 | assert.Len(updated2, 0, "applying to already-invalid path should be a no-op") |
| 170 | } |
| 171 | |
| 172 | func TestApplyToPathList_ReachableSetsMED(t *testing.T) { |
| 173 | assert := assert.New(t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…