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

Function TestPeerIndexByNodeID

types/netmap/netmap_test.go:294–320  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

292}
293
294func TestPeerIndexByNodeID(t *testing.T) {
295 var nilPtr *NetworkMap
296 if nilPtr.PeerIndexByNodeID(123) != -1 {
297 t.Errorf("nil PeerIndexByNodeID should return -1")
298 }
299 var nm NetworkMap
300 const min = 2
301 const max = 10000
302 const hole = max / 2
303 for nid := tailcfg.NodeID(2); nid <= max; nid++ {
304 if nid == hole {
305 continue
306 }
307 nm.Peers = append(nm.Peers, (&tailcfg.Node{ID: nid}).View())
308 }
309 for want, nv := range nm.Peers {
310 got := nm.PeerIndexByNodeID(nv.ID())
311 if got != want {
312 t.Errorf("PeerIndexByNodeID(%v) = %v; want %v", nv.ID(), got, want)
313 }
314 }
315 for _, miss := range []tailcfg.NodeID{min - 1, hole, max + 1} {
316 if got := nm.PeerIndexByNodeID(miss); got != -1 {
317 t.Errorf("PeerIndexByNodeID(%v) = %v; want -1", miss, got)
318 }
319 }
320}
321
322func TestNoPrivateKeyMaterial(t *testing.T) {
323 private := key.PrivateTypesForTest()

Callers

nothing calls this directly

Calls 5

PeerIndexByNodeIDMethod · 0.95
NodeIDTypeAlias · 0.92
ErrorfMethod · 0.65
ViewMethod · 0.65
IDMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…