(t *testing.T)
| 439 | } |
| 440 | |
| 441 | func TestNodeUpdater_setCallback(t *testing.T) { |
| 442 | t.Parallel() |
| 443 | ctx := testutil.Context(t, testutil.WaitShort) |
| 444 | logger := testutil.Logger(t) |
| 445 | id := tailcfg.NodeID(1) |
| 446 | nodeKey := key.NewNode().Public() |
| 447 | discoKey := key.NewDisco().Public() |
| 448 | uut := newNodeUpdater( |
| 449 | logger, |
| 450 | nil, |
| 451 | id, nodeKey, discoKey, |
| 452 | ) |
| 453 | defer uut.close() |
| 454 | |
| 455 | // Given: preferred DERP is 1 |
| 456 | addrs := []netip.Prefix{netip.MustParsePrefix("192.168.0.200/32")} |
| 457 | uut.L.Lock() |
| 458 | uut.preferredDERP = 1 |
| 459 | uut.addresses = slices.Clone(addrs) |
| 460 | uut.L.Unlock() |
| 461 | |
| 462 | // When: we set callback |
| 463 | nodeCh := make(chan *Node) |
| 464 | uut.setCallback(func(n *Node) { |
| 465 | nodeCh <- n |
| 466 | }) |
| 467 | |
| 468 | // Then: we get a node update |
| 469 | node := testutil.TryReceive(ctx, t, nodeCh) |
| 470 | require.Equal(t, nodeKey, node.Key) |
| 471 | require.Equal(t, discoKey, node.DiscoKey) |
| 472 | require.Equal(t, 1, node.PreferredDERP) |
| 473 | |
| 474 | done := make(chan struct{}) |
| 475 | go func() { |
| 476 | defer close(done) |
| 477 | uut.close() |
| 478 | }() |
| 479 | _ = testutil.TryReceive(ctx, t, done) |
| 480 | } |
| 481 | |
| 482 | func TestNodeUpdater_setBlockEndpoints_different(t *testing.T) { |
| 483 | t.Parallel() |
nothing calls this directly
no test coverage detected