MCPcopy Index your code
hub / github.com/tailscale/tailscale / TestUserspaceEngineTSMPLearnedMismatch

Function TestUserspaceEngineTSMPLearnedMismatch

wgengine/userspace_test.go:167–253  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

165}
166
167func TestUserspaceEngineTSMPLearnedMismatch(t *testing.T) {
168 bus := eventbustest.NewBus(t)
169
170 ht := health.NewTracker(bus)
171 reg := new(usermetric.Registry)
172 e, err := NewFakeUserspaceEngine(t.Logf, 0, ht, reg, bus)
173 if err != nil {
174 t.Fatal(err)
175 }
176 t.Cleanup(e.Close)
177 ue := e.(*userspaceEngine)
178
179 discoChangedChan := make(chan map[key.NodePublic]bool, 1)
180 ue.testDiscoChangedHook = func(m map[key.NodePublic]bool) {
181 discoChangedChan <- m
182 }
183
184 routerCfg := &router.Config{}
185 var metricValue int64 = 0
186
187 keyChanges := []struct {
188 tsmp bool
189 inMap bool
190 wrongKey bool
191 }{
192 {tsmp: false, inMap: false, wrongKey: false},
193 {tsmp: true, inMap: false, wrongKey: false},
194 {tsmp: true, inMap: true, wrongKey: true},
195 {tsmp: false, inMap: true, wrongKey: false},
196 }
197
198 nkHex := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
199 for _, change := range keyChanges {
200 oldDisco := key.NewDisco()
201 nm := &netmap.NetworkMap{
202 Peers: nodeViews([]*tailcfg.Node{
203 {
204 ID: 1,
205 Key: nkFromHex(nkHex),
206 DiscoKey: oldDisco.Public(),
207 },
208 }),
209 }
210 nk, err := key.ParseNodePublicUntyped(mem.S(nkHex))
211 if err != nil {
212 t.Fatal(err)
213 }
214 e.SetNetworkMap(nm)
215
216 newDisco := key.NewDisco()
217 cfg := &wgcfg.Config{
218 Peers: []wgcfg.Peer{
219 {
220 PublicKey: nk,
221 DiscoKey: newDisco.Public(),
222 },
223 },
224 }

Callers

nothing calls this directly

Calls 15

NewBusFunction · 0.92
NewTrackerFunction · 0.92
NewDiscoFunction · 0.92
ParseNodePublicUntypedFunction · 0.92
NewFakeUserspaceEngineFunction · 0.85
nkFromHexFunction · 0.85
nodeViewsFunction · 0.70
FatalMethod · 0.65
CleanupMethod · 0.65
SetNetworkMapMethod · 0.65
PatchDiscoKeyMethod · 0.65
ReconfigMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…