MCPcopy Create free account
hub / github.com/encodeous/nylon / TestEndpointResolution

Function TestEndpointResolution

e2e/resolution_test.go:17–121  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestEndpointResolution(t *testing.T) {
18 t.Parallel()
19 h := NewHarness(t)
20
21 dnsIP := GetIP(h.Subnet, 100)
22 node1IP := GetIP(h.Subnet, 2)
23 node2IP := GetIP(h.Subnet, 3)
24
25 // example.com -> node1IP
26 // srv.example.com -> SRV _nylon._udp.srv.example.com -> 57175 node2.example.com
27 // node2.example.com -> node2IP
28 corefile := `
29. {
30 file /etc/coredns/example.com.db example.com
31 log
32 errors
33}
34`
35 zoneFile := fmt.Sprintf(`
36example.com. 0 IN SOA sns.dns.icann.org. noc.dns.icann.org. 2017042745 7200 3600 1209600 0
37example.com. 0 IN A %s
38node2.example.com. 0 IN A %s
39_nylon._udp.srv.example.com. 0 IN SRV 10 10 57175 node2.example.com.
40`, node1IP, node2IP)
41 h.StartDNS("dns", dnsIP, corefile, map[string]string{"example.com.db": zoneFile})
42
43 key1 := state.GenerateKey()
44 key2 := state.GenerateKey()
45
46 centralCfg := state.CentralCfg{
47 Routers: []state.RouterCfg{
48 {
49 NodeCfg: state.NodeCfg{
50 Id: "node-1",
51 PubKey: key1.Pubkey(),
52 Addresses: []netip.Addr{netip.MustParseAddr("10.0.0.1")},
53 },
54 // Node 1's endpoint is a hostname
55 Endpoints: []*state.DynamicEndpoint{
56 state.NewDynamicEndpoint("example.com"),
57 },
58 },
59 {
60 NodeCfg: state.NodeCfg{
61 Id: "node-2",
62 PubKey: key2.Pubkey(),
63 Addresses: []netip.Addr{netip.MustParseAddr("10.0.0.2")},
64 },
65 // Node 2's endpoint is an SRV record
66 Endpoints: []*state.DynamicEndpoint{
67 state.NewDynamicEndpoint("srv.example.com"),
68 },
69 },
70 },
71 Graph: []string{"node-1, node-2"},
72 }
73
74 testDir := h.SetupTestDir()

Callers

nothing calls this directly

Calls 15

StartDNSMethod · 0.95
SetupTestDirMethod · 0.95
WriteConfigMethod · 0.95
StartNodeMethod · 0.95
WaitForLogMethod · 0.95
ExecMethod · 0.95
ReadStatusMethod · 0.95
GenerateKeyFunction · 0.92
NewDynamicEndpointFunction · 0.92
NewHarnessFunction · 0.85
GetIPFunction · 0.85
SimpleLocalFunction · 0.85

Tested by

no test coverage detected