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

Function TestRouterNet1A_BasicRetraction

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

Source from the content-addressed store, hash-verified

53}
54
55func TestRouterNet1A_BasicRetraction(t *testing.T) {
56 tunables := ConfigureConstants()
57 // This test is for the following network with our router being A:
58 // B
59 // 1 /|
60 // 1 / |
61 // S --- A |1
62 // \ |
63 // 1 \|
64 // C
65
66 h := &RouterHarness{}
67 aPrefix := nodeToPrefix("A")
68 rs := &state.RouterState{
69 RouterTunables: tunables,
70 Id: "A",
71 SelfSeqno: make(map[netip.Prefix]uint16),
72 Routes: make(map[netip.Prefix]state.SelRoute),
73 Sources: make(map[state.Source]state.FD),
74 Neighbours: MakeNeighbours("S", "B", "C"),
75 Advertised: map[netip.Prefix]state.Advertisement{aPrefix: {NodeId: state.NodeId("A"), Expiry: maxTime}},
76 }
77
78 sr := AddLink(rs, NewMockEndpoint("S", 1))
79 _ = AddLink(rs, NewMockEndpoint("B", 1))
80 _ = AddLink(rs, NewMockEndpoint("C", 1))
81
82 // S's advertised routes
83 h.NeighUpdate(rs, "S", "S", nodeToPrefix("S"), 0, 0)
84 h.NeighUpdate(rs, "S", "A", nodeToPrefix("A"), 0, 1)
85 h.NeighUpdate(rs, "S", "B", nodeToPrefix("B"), 0, 2)
86 h.NeighUpdate(rs, "S", "C", nodeToPrefix("C"), 0, 2)
87
88 // B's advertised routes
89 h.NeighUpdate(rs, "B", "B", nodeToPrefix("B"), 0, 0)
90 h.NeighUpdate(rs, "B", "A", nodeToPrefix("A"), 0, 1)
91 h.NeighUpdate(rs, "B", "C", nodeToPrefix("C"), 0, 1)
92 h.NeighUpdate(rs, "B", "S", nodeToPrefix("S"), 0, 2)
93
94 // C's advertised routes
95 h.NeighUpdate(rs, "C", "C", nodeToPrefix("C"), 0, 0)
96 h.NeighUpdate(rs, "C", "A", nodeToPrefix("A"), 0, 1)
97 h.NeighUpdate(rs, "C", "B", nodeToPrefix("B"), 0, 1)
98 h.NeighUpdate(rs, "C", "S", nodeToPrefix("S"), 0, 2)
99
100 ComputeRoutes(rs, h)
101 a := h.GetActions()
102 a.AssertEqual(t,
103 BroadcastUpdateRoute(MakePubRoute("A", nodeToPrefix("A"), 0, 0)),
104 BroadcastUpdateRoute(MakePubRoute("B", nodeToPrefix("B"), 0, 1)),
105 BroadcastUpdateRoute(MakePubRoute("C", nodeToPrefix("C"), 0, 1)),
106 BroadcastUpdateRoute(MakePubRoute("S", nodeToPrefix("S"), 0, 1)),
107 )
108 assert.Equal(t, `10.0.0.1/32 via (nh: A, router: A, prefix: 10.0.0.1/32, seqno: 0, metric: 0)
10910.0.0.19/32 via (nh: S, router: S, prefix: 10.0.0.19/32, seqno: 0, metric: 1)
11010.0.0.2/32 via (nh: B, router: B, prefix: 10.0.0.2/32, seqno: 0, metric: 1)
11110.0.0.3/32 via (nh: C, router: C, prefix: 10.0.0.3/32, seqno: 0, metric: 1)`, rs.StringRoutes())
112

Callers

nothing calls this directly

Calls 15

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

Tested by

no test coverage detected