MCPcopy Index your code
hub / github.com/coder/coder / TestNodeUpdater_setAddresses_different

Function TestNodeUpdater_setAddresses_different

tailnet/node_internal_test.go:361–400  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

359}
360
361func TestNodeUpdater_setAddresses_different(t *testing.T) {
362 t.Parallel()
363 ctx := testutil.Context(t, testutil.WaitShort)
364 logger := testutil.Logger(t)
365 id := tailcfg.NodeID(1)
366 nodeKey := key.NewNode().Public()
367 discoKey := key.NewDisco().Public()
368 nodeCh := make(chan *Node)
369 uut := newNodeUpdater(
370 logger,
371 func(n *Node) {
372 nodeCh <- n
373 },
374 id, nodeKey, discoKey,
375 )
376 defer uut.close()
377
378 // Given: preferred DERP is 1, so we'll send an update
379 uut.L.Lock()
380 uut.preferredDERP = 1
381 uut.L.Unlock()
382
383 // When: we set addresses
384 addrs := []netip.Prefix{netip.MustParsePrefix("192.168.0.200/32")}
385 uut.setAddresses(addrs)
386
387 // Then: we receive an update with the addresses
388 node := testutil.TryReceive(ctx, t, nodeCh)
389 require.Equal(t, nodeKey, node.Key)
390 require.Equal(t, discoKey, node.DiscoKey)
391 require.Equal(t, addrs, node.Addresses)
392 require.Equal(t, addrs, node.AllowedIPs)
393
394 done := make(chan struct{})
395 go func() {
396 defer close(done)
397 uut.close()
398 }()
399 _ = testutil.TryReceive(ctx, t, done)
400}
401
402func TestNodeUpdater_setAddresses_same(t *testing.T) {
403 t.Parallel()

Callers

nothing calls this directly

Calls 9

ContextFunction · 0.92
LoggerFunction · 0.92
TryReceiveFunction · 0.92
newNodeUpdaterFunction · 0.85
closeMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45
setAddressesMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected