(t *testing.T)
| 415 | } |
| 416 | |
| 417 | func TestTSMPKeyAdvertisement(t *testing.T) { |
| 418 | var knobs controlknobs.Knobs |
| 419 | |
| 420 | bus := eventbustest.NewBus(t) |
| 421 | ht := health.NewTracker(bus) |
| 422 | reg := new(usermetric.Registry) |
| 423 | e, err := NewFakeUserspaceEngine(t.Logf, 0, &knobs, ht, reg, bus) |
| 424 | if err != nil { |
| 425 | t.Fatal(err) |
| 426 | } |
| 427 | t.Cleanup(e.Close) |
| 428 | ue := e.(*userspaceEngine) |
| 429 | routerCfg := &router.Config{} |
| 430 | nodeKey := nkFromHex("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb") |
| 431 | nm := &netmap.NetworkMap{ |
| 432 | Peers: nodeViews([]*tailcfg.Node{ |
| 433 | { |
| 434 | ID: 1, |
| 435 | Key: nodeKey, |
| 436 | }, |
| 437 | }), |
| 438 | SelfNode: (&tailcfg.Node{ |
| 439 | StableID: "TESTCTRL00000001", |
| 440 | Name: "test-node.test.ts.net", |
| 441 | Addresses: []netip.Prefix{netip.MustParsePrefix("100.64.0.1/32"), netip.MustParsePrefix("fd7a:115c:a1e0:ab12:4843:cd96:0:1/128")}, |
| 442 | }).View(), |
| 443 | } |
| 444 | cfg := &wgcfg.Config{ |
| 445 | Peers: []wgcfg.Peer{ |
| 446 | { |
| 447 | PublicKey: nodeKey, |
| 448 | AllowedIPs: []netip.Prefix{ |
| 449 | netip.PrefixFrom(netaddr.IPv4(100, 100, 99, 1), 32), |
| 450 | }, |
| 451 | }, |
| 452 | }, |
| 453 | } |
| 454 | |
| 455 | ue.SetNetworkMap(nm) |
| 456 | err = ue.Reconfig(cfg, routerCfg, &dns.Config{}) |
| 457 | if err != nil { |
| 458 | t.Fatal(err) |
| 459 | } |
| 460 | |
| 461 | addr := netip.MustParseAddr("100.100.99.1") |
| 462 | previousValue := metricTSMPDiscoKeyAdvertisementSent.Value() |
| 463 | ue.sendTSMPDiscoAdvertisement(addr) |
| 464 | if val := metricTSMPDiscoKeyAdvertisementSent.Value(); val <= previousValue { |
| 465 | errs := metricTSMPDiscoKeyAdvertisementError.Value() |
| 466 | t.Errorf("Expected 1 disco key advert, got %d, errors %d", val, errs) |
| 467 | } |
| 468 | // Remove config to have the engine shut down more consistently |
| 469 | err = ue.Reconfig(&wgcfg.Config{}, &router.Config{}, &dns.Config{}) |
| 470 | if err != nil { |
| 471 | t.Fatal(err) |
| 472 | } |
| 473 | } |
| 474 |
nothing calls this directly
no test coverage detected
searching dependent graphs…