(t *testing.T)
| 292 | } |
| 293 | |
| 294 | func 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 | |
| 322 | func TestNoPrivateKeyMaterial(t *testing.T) { |
| 323 | private := key.PrivateTypesForTest() |
nothing calls this directly
no test coverage detected
searching dependent graphs…