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

Function TestRecoveryExample

e2e/recovery_test.go:13–137  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestRecoveryExample(t *testing.T) {
14 t.Parallel()
15 h := NewHarness(t)
16
17 // Node names
18 alice := "alice"
19 bob := "bob"
20 charlie := "charlie"
21 eve := "eve"
22 vps := "vps"
23 nodeNames := []string{alice, bob, charlie, eve, vps}
24
25 // Generate keys
26 keys := make(map[string]state.NyPrivateKey)
27 pubKeys := make(map[string]state.NyPublicKey)
28 for _, name := range nodeNames {
29 k := state.GenerateKey()
30 keys[name] = k
31 pubKeys[name] = k.Pubkey()
32 }
33
34 // Internal Nylon IPs (10.0.0.x)
35 nylonIPs := make(map[string]string)
36 for i, name := range nodeNames {
37 nylonIPs[name] = fmt.Sprintf("10.0.0.%d", i+1)
38 }
39
40 // Docker IPs
41 dockerIPs := make(map[string]string)
42 for i, name := range nodeNames {
43 dockerIPs[name] = GetIP(h.Subnet, 10+i)
44 }
45
46 configDir := h.SetupTestDir()
47
48 // 1. Create Central Config
49 central := state.CentralCfg{
50 Routers: []state.RouterCfg{
51 SimpleRouter(alice, pubKeys[alice], nylonIPs[alice], dockerIPs[alice]),
52 SimpleRouter(bob, pubKeys[bob], nylonIPs[bob], dockerIPs[bob]),
53 SimpleRouter(charlie, pubKeys[charlie], nylonIPs[charlie], dockerIPs[charlie]),
54 SimpleRouter(eve, pubKeys[eve], nylonIPs[eve], dockerIPs[eve]),
55 SimpleRouter(vps, pubKeys[vps], nylonIPs[vps], dockerIPs[vps]),
56 },
57 Graph: []string{
58 "vps, charlie",
59 "vps, alice",
60 "eve, bob",
61 "vps, eve",
62 "alice, bob",
63 },
64 Timestamp: time.Now().UnixNano(),
65 }
66
67 centralPath := h.WriteConfig(configDir, "central.yaml", central)
68
69 // 2. Create Node Configs & Start Nodes
70 nodeSpecs := make([]NodeSpec, 0, len(nodeNames))

Callers

nothing calls this directly

Calls 14

SetupTestDirMethod · 0.95
WriteConfigMethod · 0.95
StartNodesMethod · 0.95
WaitForLogMethod · 0.95
StartTraceMethod · 0.95
ExecMethod · 0.95
WaitForTraceMethod · 0.95
GenerateKeyFunction · 0.92
NewHarnessFunction · 0.85
GetIPFunction · 0.85
SimpleRouterFunction · 0.85
SimpleLocalFunction · 0.85

Tested by

no test coverage detected