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

Function startDistributedSingleNode

e2e/distribution_test.go:229–269  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

227}
228
229func startDistributedSingleNode(t *testing.T) (*Harness, testcontainers.Container, string, state.NyPrivateKey, state.NyPublicKey, state.NodeId, int64) {
230 t.Helper()
231 h := NewHarness(t)
232 ctx := context.Background()
233 privKey := state.GenerateKey()
234 pubKey := privKey.Pubkey()
235 runDir := h.SetupTestDir()
236
237 nodeKey := state.GenerateKey()
238 nodeId := state.NodeId("node-1")
239 cfg := state.CentralCfg{
240 Timestamp: 1,
241 Dist: &state.DistributionCfg{
242 Key: pubKey,
243 Repos: []string{"http://repo:80/bundle"},
244 },
245 Routers: []state.RouterCfg{
246 SimpleRouter(string(nodeId), nodeKey.Pubkey(), "10.0.0.1", ""),
247 },
248 }
249 bundlePath, timestamp := writeBundle(t, runDir, "bundle-initial", cfg, privKey)
250
251 repoContainer := startBundleRepo(t, h, ctx, bundlePath)
252 centralConfigPath := h.WriteConfig(runDir, "central.yaml", withTimestamp(cfg, timestamp))
253 nodeCfg := SimpleLocal(string(nodeId), nodeKey)
254 nodeCfg.Dist = &state.LocalDistributionCfg{
255 Key: pubKey,
256 Url: "http://repo:80/bundle",
257 }
258 nodeConfigPath := h.WriteConfig(runDir, "node.yaml", nodeCfg)
259
260 h.StartNodes(NodeSpec{
261 Name: string(nodeId),
262 IP: GetIP(h.Subnet, 10),
263 CentralConfigPath: centralConfigPath,
264 NodeConfigPath: nodeConfigPath,
265 })
266 h.WaitForLog(string(nodeId), "Nylon has been initialized")
267
268 return h, repoContainer, runDir, privKey, pubKey, nodeId, timestamp
269}
270
271func startBundleRepo(t *testing.T, h *Harness, ctx context.Context, bundlePath string) testcontainers.Container {
272 t.Helper()

Calls 14

SetupTestDirMethod · 0.95
WriteConfigMethod · 0.95
StartNodesMethod · 0.95
WaitForLogMethod · 0.95
GenerateKeyFunction · 0.92
NodeIdTypeAlias · 0.92
NewHarnessFunction · 0.85
SimpleRouterFunction · 0.85
writeBundleFunction · 0.85
startBundleRepoFunction · 0.85
withTimestampFunction · 0.85
SimpleLocalFunction · 0.85

Tested by

no test coverage detected