mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-01 14:05:39 +00:00
fe7c3e9c17
This is mostly code movement from the wireguard-go repo. Most of the new wgcfg package corresponds to the wireguard-go wgcfg package. wgengine/wgcfg/device{_test}.go was device/config{_test}.go. There were substantive but simple changes to device_test.go to remove internal package device references. The API of device.Config (now wgcfg.DeviceConfig) grew an error return; we previously logged the error and threw it away. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
67 lines
1.4 KiB
Go
67 lines
1.4 KiB
Go
// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package deepprint
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
"inet.af/netaddr"
|
|
"tailscale.com/wgengine/router"
|
|
"tailscale.com/wgengine/router/dns"
|
|
"tailscale.com/wgengine/wgcfg"
|
|
)
|
|
|
|
func TestDeepPrint(t *testing.T) {
|
|
// v contains the types of values we care about for our current callers.
|
|
// Mostly we're just testing that we don't panic on handled types.
|
|
v := getVal()
|
|
|
|
var buf bytes.Buffer
|
|
Print(&buf, v)
|
|
t.Logf("Got: %s", buf.Bytes())
|
|
|
|
hash1 := Hash(v)
|
|
t.Logf("hash: %v", hash1)
|
|
for i := 0; i < 20; i++ {
|
|
hash2 := Hash(getVal())
|
|
if hash1 != hash2 {
|
|
t.Error("second hash didn't match")
|
|
}
|
|
}
|
|
}
|
|
|
|
func getVal() []interface{} {
|
|
return []interface{}{
|
|
&wgcfg.Config{
|
|
Name: "foo",
|
|
Addresses: []netaddr.IPPrefix{{Bits: 5, IP: netaddr.IPFrom16([16]byte{3: 3})}},
|
|
ListenPort: 5,
|
|
Peers: []wgcfg.Peer{
|
|
{
|
|
Endpoints: "foo:5",
|
|
},
|
|
},
|
|
},
|
|
&router.Config{
|
|
DNS: dns.Config{
|
|
Nameservers: []netaddr.IP{netaddr.IPv4(8, 8, 8, 8)},
|
|
Domains: []string{"tailscale.net"},
|
|
},
|
|
},
|
|
map[string]string{
|
|
"key1": "val1",
|
|
"key2": "val2",
|
|
"key3": "val3",
|
|
"key4": "val4",
|
|
"key5": "val5",
|
|
"key6": "val6",
|
|
"key7": "val7",
|
|
"key8": "val8",
|
|
"key9": "val9",
|
|
},
|
|
}
|
|
}
|