MCPcopy Create free account
hub / github.com/encodeous/nylon / TestRouterNet3A_HandleRetraction

Function TestRouterNet3A_HandleRetraction

core/router_test.go:254–331  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

252}
253
254func TestRouterNet3A_HandleRetraction(t *testing.T) {
255 tunables := ConfigureConstants()
256 // This test is for the following network with our router being A:
257 // 2
258 // B ---- D
259 // 1 /| /
260 // / | /
261 // A |1 / 1
262 // \ | /
263 // 3 \| /
264 // C
265
266 h := &RouterHarness{}
267 rs := &state.RouterState{
268 RouterTunables: tunables,
269 Id: "A",
270 SelfSeqno: make(map[netip.Prefix]uint16),
271 Routes: make(map[netip.Prefix]state.SelRoute),
272 Sources: make(map[state.Source]state.FD),
273 Neighbours: MakeNeighbours("B", "C"),
274 Advertised: map[netip.Prefix]state.Advertisement{nodeToPrefix("A"): {NodeId: state.NodeId("A"), Expiry: maxTime}},
275 }
276
277 _ = AddLink(rs, NewMockEndpoint("B", 1))
278 _ = AddLink(rs, NewMockEndpoint("C", 3))
279
280 // B's advertised routes
281 h.NeighUpdate(rs, "B", "A", nodeToPrefix("A"), 0, 1)
282 h.NeighUpdate(rs, "B", "B", nodeToPrefix("B"), 0, 0)
283 h.NeighUpdate(rs, "B", "C", nodeToPrefix("C"), 0, 1)
284 h.NeighUpdate(rs, "B", "D", nodeToPrefix("D"), 0, 2)
285
286 // C's advertised routes
287 h.NeighUpdate(rs, "C", "A", nodeToPrefix("A"), 0, 3)
288 h.NeighUpdate(rs, "C", "B", nodeToPrefix("B"), 0, 1)
289 h.NeighUpdate(rs, "C", "C", nodeToPrefix("C"), 0, 0)
290 h.NeighUpdate(rs, "C", "D", nodeToPrefix("D"), 0, 1)
291
292 ComputeRoutes(rs, h)
293 a := h.GetActions()
294 // check that we converge to the correct table
295 a.AssertEqual(t,
296 BroadcastUpdateRoute(MakePubRoute("A", nodeToPrefix("A"), 0, 0)),
297 BroadcastUpdateRoute(MakePubRoute("B", nodeToPrefix("B"), 0, 1)),
298 BroadcastUpdateRoute(MakePubRoute("C", nodeToPrefix("C"), 0, 2)),
299 BroadcastUpdateRoute(MakePubRoute("D", nodeToPrefix("D"), 0, 3)),
300 )
301 assert.Equal(t, `10.0.0.1/32 via (nh: A, router: A, prefix: 10.0.0.1/32, seqno: 0, metric: 0)
30210.0.0.2/32 via (nh: B, router: B, prefix: 10.0.0.2/32, seqno: 0, metric: 1)
30310.0.0.3/32 via (nh: B, router: C, prefix: 10.0.0.3/32, seqno: 0, metric: 2)
30410.0.0.4/32 via (nh: B, router: D, prefix: 10.0.0.4/32, seqno: 0, metric: 3)`, rs.StringRoutes())
305
306 // Suppose now that the link between B and C goes down
307 // 2
308 // B ---- D
309 // 1 / /
310 // / /
311 // A / 1

Callers

nothing calls this directly

Calls 15

NeighUpdateMethod · 0.95
GetActionsMethod · 0.95
StringRoutesMethod · 0.95
NodeIdTypeAlias · 0.92
ConfigureConstantsFunction · 0.85
MakeNeighboursFunction · 0.85
nodeToPrefixFunction · 0.85
AddLinkFunction · 0.85
NewMockEndpointFunction · 0.85
ComputeRoutesFunction · 0.85
BroadcastUpdateRouteFunction · 0.85
MakePubRouteFunction · 0.85

Tested by

no test coverage detected