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

Function TestRouter_SeqnoRequestNotForwardedBackToRequester

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

Source from the content-addressed store, hash-verified

513}
514
515func TestRouter_SeqnoRequestNotForwardedBackToRequester(t *testing.T) {
516 tunables := ConfigureConstants()
517 // This test is for the following network with our router being A:
518 // A has a stale selected route to S through requester B. In A's neighbour
519 // table, B is still the only feasible route for S, while C has an older
520 // route to S. If B loses its route and asks A for a newer seqno before A
521 // has processed B's retraction, A must not forward the request back to B.
522 //
523 // B (stale route to S at metric 1)
524 // | 1
525 // A
526 // | 1
527 // C (older route to S at metric 3)
528 //
529 // A selected route: S via B, seqno 0, metric 2
530 // B asks A for: S seqno 1
531 // Expected: A forwards to C
532 // Forbidden: A forwards back to B
533
534 h := &RouterHarness{}
535 sPrefix := nodeToPrefix("S")
536 rs := &state.RouterState{
537 RouterTunables: tunables,
538 Id: "A",
539 SelfSeqno: make(map[netip.Prefix]uint16),
540 Routes: make(map[netip.Prefix]state.SelRoute),
541 Sources: make(map[state.Source]state.FD),
542 Neighbours: MakeNeighbours("B", "C"),
543 Advertised: map[netip.Prefix]state.Advertisement{nodeToPrefix("A"): {NodeId: state.NodeId("A"), Expiry: maxTime}},
544 }
545
546 _ = AddLink(rs, NewMockEndpoint("B", 1))
547 _ = AddLink(rs, NewMockEndpoint("C", 1))
548
549 h.NeighUpdate(rs, "C", "S", sPrefix, 0, 3)
550 h.NeighUpdate(rs, "B", "S", sPrefix, 0, 1)
551 ComputeRoutes(rs, h)
552 assert.Equal(t, "B", string(rs.Routes[sPrefix].Nh))
553 assert.Equal(t, state.FD{Seqno: 0, Metric: 2}, rs.Sources[state.Source{NodeId: "S", Prefix: sPrefix}])
554 h.GetActions()
555
556 HandleSeqnoRequest(rs, h, "B", state.Source{NodeId: "S", Prefix: sPrefix}, 1, 64)
557 a := h.GetActions()
558 a.AssertNotContains(t, RequestSeqno("B", state.Source{NodeId: "S", Prefix: sPrefix}, 1, 63))
559 a.AssertContains(t, RequestSeqno("C", state.Source{NodeId: "S", Prefix: sPrefix}, 1, 63))
560}
561
562func TestRouterNet5A_SelectedUnfeasibleUpdate(t *testing.T) {
563 tunables := ConfigureConstants()

Callers

nothing calls this directly

Calls 13

NeighUpdateMethod · 0.95
GetActionsMethod · 0.95
NodeIdTypeAlias · 0.92
ConfigureConstantsFunction · 0.85
nodeToPrefixFunction · 0.85
MakeNeighboursFunction · 0.85
AddLinkFunction · 0.85
NewMockEndpointFunction · 0.85
ComputeRoutesFunction · 0.85
HandleSeqnoRequestFunction · 0.85
RequestSeqnoFunction · 0.85
AssertNotContainsMethod · 0.80

Tested by

no test coverage detected