MCPcopy Create free account
hub / github.com/containers/common / TestGetRandomIPv6Subnet

Function TestGetRandomIPv6Subnet

libnetwork/internal/util/ip_test.go:43–63  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

41}
42
43func TestGetRandomIPv6Subnet(t *testing.T) {
44 for i := 0; i < 1000; i++ {
45 t.Run(fmt.Sprintf("GetRandomIPv6Subnet %d", i), func(t *testing.T) {
46 sub, err := getRandomIPv6Subnet()
47 if err != nil {
48 t.Errorf("GetRandomIPv6Subnet() error should be nil: %v", err)
49 return
50 }
51 if sub.IP.To4() != nil {
52 t.Errorf("ip %s is not an ipv6 address", sub.IP)
53 }
54 if sub.IP[0] != 0xfd {
55 t.Errorf("ipv6 %s does not start with fd", sub.IP)
56 }
57 ones, bytes := sub.Mask.Size()
58 if ones != 64 || bytes != 128 {
59 t.Errorf("wrong network mask %v, it should be /64", sub.Mask)
60 }
61 })
62 }
63}

Callers

nothing calls this directly

Calls 2

getRandomIPv6SubnetFunction · 0.85
SizeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…