MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / TestNodeStartStop

Function TestNodeStartStop

node/node_test.go:37–78  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35)
36
37func TestNodeStartStop(t *testing.T) {
38 config := cfg.ResetTestRoot("node_node_test")
39 defer os.RemoveAll(config.RootDir)
40
41 // create & start node
42 n, err := DefaultNewNode(config, log.TestingLogger())
43 require.NoError(t, err)
44 err = n.Start()
45 require.NoError(t, err)
46
47 t.Logf("Started node %v", n.sw.NodeInfo())
48
49 // wait for the node to produce a block
50 blocksSub, err := n.EventBus().Subscribe(context.Background(), "node_test", types.EventQueryNewBlock)
51 require.NoError(t, err)
52 select {
53 case <-blocksSub.Out():
54 case <-blocksSub.Cancelled():
55 t.Fatal("blocksSub was cancelled")
56 case <-time.After(10 * time.Second):
57 t.Fatal("timed out waiting for the node to produce a block")
58 }
59
60 // stop the node
61 go func() {
62 err = n.Stop()
63 require.NoError(t, err)
64 }()
65
66 select {
67 case <-n.Quit():
68 case <-time.After(5 * time.Second):
69 pid := os.Getpid()
70 p, err := os.FindProcess(pid)
71 if err != nil {
72 panic(err)
73 }
74 err = p.Signal(syscall.SIGABRT)
75 fmt.Println(err)
76 t.Fatal("timed out waiting for shutdown")
77 }
78}
79
80func TestSplitAndTrimEmpty(t *testing.T) {
81 testCases := []struct {

Callers

nothing calls this directly

Calls 10

TestingLoggerFunction · 0.92
DefaultNewNodeFunction · 0.70
StartMethod · 0.65
NodeInfoMethod · 0.65
SubscribeMethod · 0.65
OutMethod · 0.65
CancelledMethod · 0.65
StopMethod · 0.65
QuitMethod · 0.65
EventBusMethod · 0.45

Tested by

no test coverage detected