shutdown daemon after test (#11135)
Andrew Gillis committed
Jan 7, 2026 at 20:51 UTC
aa3c88dcdd84a16286354a3a4526ee5442daf651
27 files changed
+122
-3
test/cli/backup_bootstrap_test.go
+3
@@ -39,7 +39,9 @@ func TestBackupBootstrapPeers(t *testing.T) {
39
40
// Start 1 and 2. 2 does not know anyone yet.
41
nodes[1].StartDaemon()
42
+ defer nodes[1].StopDaemon()
43
nodes[2].StartDaemon()
44
+ defer nodes[2].StopDaemon()
45
assert.Len(t, nodes[1].Peers(), 0)
46
assert.Len(t, nodes[2].Peers(), 0)
47
@@ -51,6 +53,7 @@ func TestBackupBootstrapPeers(t *testing.T) {
53
// Start 0, wait a bit. Should connect to 1, and then discover 2 via the
54
// backup bootstrap peers.
55
nodes[0].StartDaemon()
56
+ defer nodes[0].StopDaemon()
57
time.Sleep(time.Millisecond * 500)
58
59
// Check if they're all connected.
test/cli/bitswap_config_test.go
+10
@@ -22,7 +22,9 @@ func TestBitswapConfig(t *testing.T) {
22
t.Parallel()
23
h := harness.NewT(t)
24
provider := h.NewNode().Init().StartDaemon()
25
+ defer provider.StopDaemon()
26
requester := h.NewNode().Init().StartDaemon()
27
+ defer requester.StopDaemon()
28
29
hash := provider.IPFSAddStr(string(testData))
30
requester.Connect(provider)
@@ -38,8 +40,10 @@ func TestBitswapConfig(t *testing.T) {
40
provider := h.NewNode().Init()
41
provider.SetIPFSConfig("Bitswap.ServerEnabled", false)
42
provider = provider.StartDaemon()
43
+ defer provider.StopDaemon()
44
45
requester := h.NewNode().Init().StartDaemon()
46
+ defer requester.StopDaemon()
47
48
hash := provider.IPFSAddStr(string(testData))
49
requester.Connect(provider)
@@ -70,8 +74,10 @@ func TestBitswapConfig(t *testing.T) {
74
requester := h.NewNode().Init()
75
requester.SetIPFSConfig("Bitswap.ServerEnabled", false)
76
requester.StartDaemon()
77
+ defer requester.StopDaemon()
78
79
provider := h.NewNode().Init().StartDaemon()
80
+ defer provider.StopDaemon()
81
hash := provider.IPFSAddStr(string(testData))
82
requester.Connect(provider)
83
@@ -91,8 +97,10 @@ func TestBitswapConfig(t *testing.T) {
97
cfg.HTTPRetrieval.Enabled = config.True
98
})
99
requester.StartDaemon()
100
+ defer requester.StopDaemon()
101
102
provider := h.NewNode().Init().StartDaemon()
103
+ defer provider.StopDaemon()
104
hash := provider.IPFSAddStr(string(testData))
105
106
requester.Connect(provider)
@@ -126,7 +134,9 @@ func TestBitswapConfig(t *testing.T) {
134
cfg.HTTPRetrieval.Enabled = config.True
135
})
136
provider = provider.StartDaemon()
137
+ defer provider.StopDaemon()
138
requester := h.NewNode().Init().StartDaemon()
139
+ defer requester.StopDaemon()
140
requester.Connect(provider)
141
142
// read libp2p identify from remote peer, and print protocols
test/cli/content_blocking_test.go
+1
@@ -76,6 +76,7 @@ func TestContentBlocking(t *testing.T) {
76
77
// Start daemon, it should pick up denylist from $IPFS_PATH/denylists/test.deny
78
node.StartDaemon() // we need online mode for GatewayOverLibp2p tests
79
+ t.Cleanup(func() { node.StopDaemon() })
80
client := node.GatewayClient()
81
82
// First, confirm gateway works
test/cli/dag_test.go
+3
@@ -47,6 +47,8 @@ func TestDag(t *testing.T) {
47
t.Run("ipfs dag stat --enc=json", func(t *testing.T) {
48
t.Parallel()
49
node := harness.NewT(t).NewNode().Init().StartDaemon()
50
+ defer node.StopDaemon()
51
+
52
// Import fixture
53
r, err := os.Open(fixtureFile)
54
assert.Nil(t, err)
@@ -91,6 +93,7 @@ func TestDag(t *testing.T) {
93
t.Run("ipfs dag stat", func(t *testing.T) {
94
t.Parallel()
95
node := harness.NewT(t).NewNode().Init().StartDaemon()
96
+ defer node.StopDaemon()
97
r, err := os.Open(fixtureFile)
98
assert.NoError(t, err)
99
defer r.Close()
test/cli/delegated_routing_v1_http_proxy_test.go
+4
@@ -60,6 +60,10 @@ func TestRoutingV1Proxy(t *testing.T) {
60
})
61
nodes[2].StartDaemon()
62
63
+ t.Cleanup(func() {
64
+ nodes.StopDaemons()
65
+ })
66
+
67
// Connect them.
68
nodes.Connect()
69
test/cli/delegated_routing_v1_http_server_test.go
+4
@@ -32,6 +32,7 @@ func TestRoutingV1Server(t *testing.T) {
32
})
33
})
34
nodes.StartDaemons().Connect()
35
+ t.Cleanup(func() { nodes.StopDaemons() })
36
return nodes
37
}
38
@@ -133,6 +134,7 @@ func TestRoutingV1Server(t *testing.T) {
134
cfg.Routing.Type = config.NewOptionalString("dht")
135
})
136
node.StartDaemon()
137
+ defer node.StopDaemon()
138
139
// Put IPNS record in lonely node. It should be accepted as it is a valid record.
140
c, err = client.New(node.GatewayURL())
@@ -196,6 +198,7 @@ func TestRoutingV1Server(t *testing.T) {
198
}
199
})
200
node.StartDaemon()
201
+ defer node.StopDaemon()
202
203
c, err := client.New(node.GatewayURL())
204
require.NoError(t, err)
@@ -238,6 +241,7 @@ func TestRoutingV1Server(t *testing.T) {
241
cfg.Bootstrap = autoconf.FallbackBootstrapPeers
242
})
243
node.StartDaemon()
244
+ defer node.StopDaemon()
245
246
c, err := client.New(node.GatewayURL())
247
require.NoError(t, err)
test/cli/dht_autoclient_test.go
+1
@@ -16,6 +16,7 @@ func TestDHTAutoclient(t *testing.T) {
16
node.IPFS("config", "Routing.Type", "autoclient")
17
})
18
nodes.StartDaemons().Connect()
19
+ t.Cleanup(func() { nodes.StopDaemons() })
20
21
t.Run("file added on node in client mode is retrievable from node in client mode", func(t *testing.T) {
22
t.Parallel()
test/cli/dht_opt_prov_test.go
+1
@@ -22,6 +22,7 @@ func TestDHTOptimisticProvide(t *testing.T) {
22
})
23
24
nodes.StartDaemons().Connect()
25
+ defer nodes.StopDaemons()
26
27
hash := nodes[0].IPFSAddStr(string(random.Bytes(100)))
28
nodes[0].IPFS("routing", "provide", hash)
test/cli/files_test.go
+14
@@ -19,6 +19,7 @@ func TestFilesCp(t *testing.T) {
19
t.Parallel()
20
21
node := harness.NewT(t).NewNode().Init().StartDaemon()
22
+ defer node.StopDaemon()
23
24
// Create simple text file
25
data := "testing files cp command"
@@ -36,6 +37,7 @@ func TestFilesCp(t *testing.T) {
37
t.Run("files cp with unsupported DAG node type fails", func(t *testing.T) {
38
t.Parallel()
39
node := harness.NewT(t).NewNode().Init().StartDaemon()
40
+ defer node.StopDaemon()
41
42
// MFS UnixFS is limited to dag-pb or raw, so we create a dag-cbor node to test this
43
jsonData := `{"data": "not a UnixFS node"}`
@@ -53,6 +55,7 @@ func TestFilesCp(t *testing.T) {
55
t.Run("files cp with invalid UnixFS data structure fails", func(t *testing.T) {
56
t.Parallel()
57
node := harness.NewT(t).NewNode().Init().StartDaemon()
58
+ defer node.StopDaemon()
59
60
// Create an invalid proto file
61
data := []byte{0xDE, 0xAD, 0xBE, 0xEF} // Invalid protobuf data
@@ -75,6 +78,7 @@ func TestFilesCp(t *testing.T) {
78
t.Run("files cp with raw node succeeds", func(t *testing.T) {
79
t.Parallel()
80
node := harness.NewT(t).NewNode().Init().StartDaemon()
81
+ defer node.StopDaemon()
82
83
// Create a raw node
84
data := "raw data"
@@ -98,6 +102,7 @@ func TestFilesCp(t *testing.T) {
102
t.Run("files cp creates intermediate directories with -p", func(t *testing.T) {
103
t.Parallel()
104
node := harness.NewT(t).NewNode().Init().StartDaemon()
105
+ defer node.StopDaemon()
106
107
// Create a simple text file and add it to IPFS
108
data := "hello parent directories"
@@ -130,6 +135,7 @@ func TestFilesRm(t *testing.T) {
135
t.Parallel()
136
137
node := harness.NewT(t).NewNode().Init().StartDaemon()
138
+ defer node.StopDaemon()
139
140
// Create a file to remove
141
node.IPFS("files", "mkdir", "/test-dir")
@@ -149,6 +155,7 @@ func TestFilesRm(t *testing.T) {
155
t.Parallel()
156
157
node := harness.NewT(t).NewNode().Init().StartDaemon()
158
+ defer node.StopDaemon()
159
160
// Create a file to remove
161
node.IPFS("files", "mkdir", "/test-dir")
@@ -166,6 +173,7 @@ func TestFilesRm(t *testing.T) {
173
t.Parallel()
174
175
node := harness.NewT(t).NewNode().Init().StartDaemon()
176
+ defer node.StopDaemon()
177
178
// Create a file to remove
179
node.IPFS("files", "mkdir", "/test-dir")
@@ -186,6 +194,7 @@ func TestFilesNoFlushLimit(t *testing.T) {
194
t.Run("reaches default limit of 256 operations", func(t *testing.T) {
195
t.Parallel()
196
node := harness.NewT(t).NewNode().Init().StartDaemon()
197
+ defer node.StopDaemon()
198
199
// Perform 256 operations with --flush=false (should succeed)
200
for i := 0; i < 256; i++ {
@@ -214,6 +223,7 @@ func TestFilesNoFlushLimit(t *testing.T) {
223
})
224
225
node.StartDaemon()
226
+ defer node.StopDaemon()
227
228
// Perform 5 operations (should succeed)
229
for i := 0; i < 5; i++ {
@@ -239,6 +249,7 @@ func TestFilesNoFlushLimit(t *testing.T) {
249
})
250
251
node.StartDaemon()
252
+ defer node.StopDaemon()
253
254
// Do 2 operations with --flush=false
255
node.IPFS("files", "mkdir", "--flush=false", "/dir1")
@@ -271,6 +282,7 @@ func TestFilesNoFlushLimit(t *testing.T) {
282
})
283
284
node.StartDaemon()
285
+ defer node.StopDaemon()
286
287
// Do 2 operations with --flush=false
288
node.IPFS("files", "mkdir", "--flush=false", "/dir1")
@@ -303,6 +315,7 @@ func TestFilesNoFlushLimit(t *testing.T) {
315
})
316
317
node.StartDaemon()
318
+ defer node.StopDaemon()
319
320
// Should be able to do many operations without error
321
for i := 0; i < 300; i++ {
@@ -322,6 +335,7 @@ func TestFilesNoFlushLimit(t *testing.T) {
335
})
336
337
node.StartDaemon()
338
+ defer node.StopDaemon()
339
340
// Mix of different MFS operations (5 operations to hit the limit)
341
node.IPFS("files", "mkdir", "--flush=false", "/testdir")
test/cli/gateway_limits_test.go
+2
@@ -28,6 +28,7 @@ func TestGatewayLimits(t *testing.T) {
28
cfg.Gateway.RetrievalTimeout = config.NewOptionalDuration(1 * time.Second)
29
})
30
node.StartDaemon()
31
+ defer node.StopDaemon()
32
33
// Add content that can be retrieved quickly
34
cid := node.IPFSAddStr("test content")
@@ -69,6 +70,7 @@ func TestGatewayLimits(t *testing.T) {
70
cfg.Gateway.RetrievalTimeout = config.NewOptionalDuration(2 * time.Second)
71
})
72
node.StartDaemon()
73
+ defer node.StopDaemon()
74
75
// Add some content - use a non-existent CID that will block during retrieval
76
// to ensure we can control timing
test/cli/gateway_range_test.go
+2
@@ -27,6 +27,7 @@ func TestGatewayHAMTDirectory(t *testing.T) {
27
// Start node
28
h := harness.NewT(t)
29
node := h.NewNode().Init("--empty-repo", "--profile=test").StartDaemon("--offline")
30
+ defer node.StopDaemon()
31
client := node.GatewayClient()
32
33
// Import fixtures
@@ -56,6 +57,7 @@ func TestGatewayHAMTRanges(t *testing.T) {
57
// Start node
58
h := harness.NewT(t)
59
node := h.NewNode().Init("--empty-repo", "--profile=test").StartDaemon("--offline")
60
+ t.Cleanup(func() { node.StopDaemon() })
61
client := node.GatewayClient()
62
63
// Import fixtures
test/cli/gateway_test.go
+10
@@ -28,6 +28,7 @@ func TestGateway(t *testing.T) {
28
t.Parallel()
29
h := harness.NewT(t)
30
node := h.NewNode().Init().StartDaemon("--offline")
31
+ t.Cleanup(func() { node.StopDaemon() })
32
cid := node.IPFSAddStr("Hello Worlds!")
33
34
peerID, err := peer.ToCid(node.PeerID()).StringOfBase(multibase.Base36)
@@ -234,6 +235,7 @@ func TestGateway(t *testing.T) {
235
cfg.API.HTTPHeaders = map[string][]string{header: values}
236
})
237
node.StartDaemon()
238
+ defer node.StopDaemon()
239
240
resp := node.APIClient().DisableRedirects().Get("/webui/")
241
assert.Equal(t, resp.Headers.Values(header), values)
@@ -257,6 +259,7 @@ func TestGateway(t *testing.T) {
259
t.Run("pprof", func(t *testing.T) {
260
t.Parallel()
261
node := harness.NewT(t).NewNode().Init().StartDaemon()
262
+ t.Cleanup(func() { node.StopDaemon() })
263
apiClient := node.APIClient()
264
t.Run("mutex", func(t *testing.T) {
265
t.Parallel()
@@ -300,6 +303,7 @@ func TestGateway(t *testing.T) {
303
t.Parallel()
304
h := harness.NewT(t)
305
node := h.NewNode().Init().StartDaemon()
306
+ t.Cleanup(func() { node.StopDaemon() })
307
308
h.WriteFile("index/index.html", "<p></p>")
309
cid := node.IPFS("add", "-Q", "-r", filepath.Join(h.Dir, "index")).Stderr.Trimmed()
@@ -367,6 +371,7 @@ func TestGateway(t *testing.T) {
371
cfg.Addresses.Gateway = config.Strings{"/ip4/127.0.0.1/tcp/32563"}
372
})
373
node.StartDaemon()
374
+ defer node.StopDaemon()
375
376
b, err := os.ReadFile(filepath.Join(node.Dir, "gateway"))
377
require.NoError(t, err)
@@ -388,6 +393,7 @@ func TestGateway(t *testing.T) {
393
assert.NoError(t, err)
394
395
nodes.StartDaemons().Connect()
396
+ t.Cleanup(func() { nodes.StopDaemons() })
397
398
t.Run("not present", func(t *testing.T) {
399
cidFoo := node2.IPFSAddStr("foo")
@@ -460,6 +466,7 @@ func TestGateway(t *testing.T) {
466
}
467
})
468
node.StartDaemon()
469
+ defer node.StopDaemon()
470
471
cidFoo := node.IPFSAddStr("foo")
472
client := node.GatewayClient()
@@ -509,6 +516,7 @@ func TestGateway(t *testing.T) {
516
517
node := harness.NewT(t).NewNode().Init()
518
node.StartDaemon()
519
+ defer node.StopDaemon()
520
client := node.GatewayClient()
521
522
res := client.Get("/ipfs/invalid-thing", func(r *http.Request) {
@@ -526,6 +534,7 @@ func TestGateway(t *testing.T) {
534
cfg.Gateway.DisableHTMLErrors = config.True
535
})
536
node.StartDaemon()
537
+ defer node.StopDaemon()
538
client := node.GatewayClient()
539
540
res := client.Get("/ipfs/invalid-thing", func(r *http.Request) {
@@ -546,6 +555,7 @@ func TestLogs(t *testing.T) {
555
t.Setenv("GOLOG_LOG_LEVEL", "info")
556
557
node := h.NewNode().Init().StartDaemon("--offline")
558
+ defer node.StopDaemon()
559
cid := node.IPFSAddStr("Hello Worlds!")
560
561
peerID, err := peer.ToCid(node.PeerID()).StringOfBase(multibase.Base36)
test/cli/http_gateway_over_libp2p_test.go
+2
@@ -32,6 +32,7 @@ func TestGatewayOverLibp2p(t *testing.T) {
32
p2pProxyNode := nodes[1]
33
34
nodes.StartDaemons().Connect()
35
+ defer nodes.StopDaemons()
36
37
// Add data to the gateway node
38
cidDataOnGatewayNode := cid.MustParse(gwNode.IPFSAddStr("Hello Worlds2!"))
@@ -65,6 +66,7 @@ func TestGatewayOverLibp2p(t *testing.T) {
66
// Enable the experimental feature and reconnect the nodes
67
gwNode.IPFS("config", "--json", "Experimental.GatewayOverLibp2p", "true")
68
gwNode.StopDaemon().StartDaemon()
69
+ t.Cleanup(func() { gwNode.StopDaemon() })
70
nodes.Connect()
71
72
// Note: the bare HTTP requests here assume that the gateway is mounted at `/`
test/cli/http_retrieval_client_test.go
+1
@@ -75,6 +75,7 @@ func TestHTTPRetrievalClient(t *testing.T) {
75
76
// Start Kubo
77
node.StartDaemon()
78
+ defer node.StopDaemon()
79
80
if debug {
81
fmt.Printf("delegatedRoutingServer.URL: %s\n", delegatedRoutingServer.URL)
test/cli/init_test.go
+1
@@ -155,6 +155,7 @@ func TestInit(t *testing.T) {
155
t.Run("ipfs init should not run while daemon is running", func(t *testing.T) {
156
t.Parallel()
157
node := harness.NewT(t).NewNode().Init().StartDaemon()
158
+ defer node.StopDaemon()
159
res := node.RunIPFS("init")
160
assert.NotEqual(t, 0, res.ExitErr.ExitCode())
161
assert.Contains(t, res.Stderr.String(), "Error: ipfs daemon is running. please stop it to run this command")
test/cli/name_test.go
+6
@@ -103,6 +103,7 @@ func TestName(t *testing.T) {
103
})
104
105
node.StartDaemon()
106
+ defer node.StopDaemon()
107
108
t.Run("Resolving self offline succeeds (daemon on)", func(t *testing.T) {
109
res = node.IPFS("name", "resolve", "--offline", "/ipns/"+name.String())
@@ -147,6 +148,7 @@ func TestName(t *testing.T) {
148
t.Run("Fails to publish in offline mode", func(t *testing.T) {
149
t.Parallel()
150
node := makeDaemon(t, nil).StartDaemon("--offline")
151
+ defer node.StopDaemon()
152
res := node.RunIPFS("name", "publish", "/ipfs/"+fixtureCid)
153
require.Error(t, res.Err)
154
require.Equal(t, 1, res.ExitCode())
@@ -157,6 +159,7 @@ func TestName(t *testing.T) {
159
t.Parallel()
160
161
node := makeDaemon(t, nil).StartDaemon()
162
+ defer node.StopDaemon()
163
ipnsName := ipns.NameFromPeer(node.PeerID()).String()
164
ipnsPath := ipns.NamespacePrefix + ipnsName
165
publishPath := "/ipfs/" + fixtureCid
@@ -187,6 +190,7 @@ func TestName(t *testing.T) {
190
t.Parallel()
191
192
node := makeDaemon(t, nil).StartDaemon()
193
+ t.Cleanup(func() { node.StopDaemon() })
194
ipnsPath := ipns.NamespacePrefix + ipns.NameFromPeer(node.PeerID()).String()
195
publishPath := "/ipfs/" + fixtureCid
196
@@ -227,6 +231,7 @@ func TestName(t *testing.T) {
231
t.Run("Inspect with verification using wrong RSA key errors", func(t *testing.T) {
232
t.Parallel()
233
node := makeDaemon(t, nil).StartDaemon()
234
+ defer node.StopDaemon()
235
236
// Prepare RSA Key 1
237
res := node.IPFS("key", "gen", "--type=rsa", "--size=4096", "key1")
@@ -299,6 +304,7 @@ func TestName(t *testing.T) {
304
t.Parallel()
305
306
node := makeDaemon(t, nil).StartDaemon()
307
+ defer node.StopDaemon()
308
publishPath1 := "/ipfs/" + fixtureCid
309
publishPath2 := "/ipfs/" + dagCid // Different content
310
name := ipns.NameFromPeer(node.PeerID())
test/cli/peering_test.go
+4
@@ -62,6 +62,7 @@ func TestPeering(t *testing.T) {
62
h, nodes := harness.CreatePeerNodes(t, 3, peerings)
63
64
nodes.StartDaemons()
65
+ defer nodes.StopDaemons()
66
assertPeerings(h, nodes, peerings)
67
68
nodes[0].Disconnect(nodes[1])
@@ -74,6 +75,7 @@ func TestPeering(t *testing.T) {
75
h, nodes := harness.CreatePeerNodes(t, 3, peerings)
76
77
nodes.StartDaemons()
78
+ defer nodes.StopDaemons()
79
assertPeerings(h, nodes, peerings)
80
81
nodes[2].Disconnect(nodes[1])
@@ -85,6 +87,7 @@ func TestPeering(t *testing.T) {
87
peerings := []harness.Peering{{From: 0, To: 1}, {From: 1, To: 0}, {From: 1, To: 2}}
88
h, nodes := harness.CreatePeerNodes(t, 3, peerings)
89
90
+ defer nodes.StopDaemons()
91
nodes[0].StartDaemon()
92
nodes[1].StartDaemon()
93
assertPeerings(h, nodes, []harness.Peering{{From: 0, To: 1}, {From: 1, To: 0}})
@@ -99,6 +102,7 @@ func TestPeering(t *testing.T) {
102
h, nodes := harness.CreatePeerNodes(t, 3, peerings)
103
104
nodes.StartDaemons()
105
+ defer nodes.StopDaemons()
106
assertPeerings(h, nodes, peerings)
107
108
nodes[2].StopDaemon()
test/cli/pin_ls_names_test.go
+3
-3
@@ -28,6 +28,9 @@ func setupTestNode(t *testing.T) *harness.Node {
28
t.Helper()
29
node := harness.NewT(t).NewNode().Init()
30
node.StartDaemon("--offline")
31
+ t.Cleanup(func() {
32
+ node.StopDaemon()
33
+ })
34
return node
35
}
36
@@ -498,7 +501,6 @@ func TestPinLsEdgeCases(t *testing.T) {
501
t.Run("invalid pin type returns error", func(t *testing.T) {
502
t.Parallel()
503
node := setupTestNode(t)
501
- defer node.StopDaemon()
504
505
// Try to list pins with invalid type
506
res := node.RunIPFS("pin", "ls", "--type=invalid")
@@ -510,7 +512,6 @@ func TestPinLsEdgeCases(t *testing.T) {
512
t.Run("non-existent path returns proper error", func(t *testing.T) {
513
t.Parallel()
514
node := setupTestNode(t)
513
- defer node.StopDaemon()
515
516
// Try to list a non-existent CID
517
fakeCID := "QmNonExistent123456789"
@@ -521,7 +522,6 @@ func TestPinLsEdgeCases(t *testing.T) {
522
t.Run("unpinned CID returns not pinned error", func(t *testing.T) {
523
t.Parallel()
524
node := setupTestNode(t)
524
- defer node.StopDaemon()
525
526
// Add content but don't pin it explicitly (it's just in blockstore)
527
unpinnedCID := node.IPFSAddStr("unpinned content", "--pin=false")
test/cli/ping_test.go
+5
@@ -15,6 +15,7 @@ func TestPing(t *testing.T) {
15
t.Run("other", func(t *testing.T) {
16
t.Parallel()
17
nodes := harness.NewT(t).NewNodes(2).Init().StartDaemons().Connect()
18
+ defer nodes.StopDaemons()
19
node1 := nodes[0]
20
node2 := nodes[1]
21
@@ -25,6 +26,7 @@ func TestPing(t *testing.T) {
26
t.Run("ping unreachable peer", func(t *testing.T) {
27
t.Parallel()
28
nodes := harness.NewT(t).NewNodes(2).Init().StartDaemons().Connect()
29
+ defer nodes.StopDaemons()
30
node1 := nodes[0]
31
32
badPeer := "QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJx"
@@ -37,6 +39,7 @@ func TestPing(t *testing.T) {
39
t.Run("self", func(t *testing.T) {
40
t.Parallel()
41
nodes := harness.NewT(t).NewNodes(2).Init().StartDaemons()
42
+ defer nodes.StopDaemons()
43
node1 := nodes[0]
44
node2 := nodes[1]
45
@@ -52,6 +55,7 @@ func TestPing(t *testing.T) {
55
t.Run("0", func(t *testing.T) {
56
t.Parallel()
57
nodes := harness.NewT(t).NewNodes(2).Init().StartDaemons().Connect()
58
+ defer nodes.StopDaemons()
59
node1 := nodes[0]
60
node2 := nodes[1]
61
@@ -63,6 +67,7 @@ func TestPing(t *testing.T) {
67
t.Run("offline", func(t *testing.T) {
68
t.Parallel()
69
nodes := harness.NewT(t).NewNodes(2).Init().StartDaemons().Connect()
70
+ defer nodes.StopDaemons()
71
node1 := nodes[0]
72
node2 := nodes[1]
73
test/cli/pinning_remote_test.go
+15
@@ -51,6 +51,7 @@ func TestRemotePinning(t *testing.T) {
51
node.IPFS("config", "--json", "Pinning.RemoteServices.svc.Policies.MFS.Enable", "true")
52
53
node.StartDaemon()
54
+ t.Cleanup(func() { node.StopDaemon() })
55
56
node.IPFS("files", "cp", "/ipfs/bafkqaaa", "/mfs-pinning-test-"+uuid.NewString())
57
node.IPFS("files", "flush")
@@ -133,6 +134,8 @@ func TestRemotePinning(t *testing.T) {
134
t.Run("pin remote service ls --stat", func(t *testing.T) {
135
t.Parallel()
136
node := harness.NewT(t).NewNode().Init().StartDaemon()
137
+ defer node.StopDaemon()
138
+
139
_, svcURL := runPinningService(t, authToken)
140
141
node.IPFS("pin", "remote", "service", "add", "svc", svcURL, authToken)
@@ -155,6 +158,7 @@ func TestRemotePinning(t *testing.T) {
158
t.Run("adding service with invalid URL fails", func(t *testing.T) {
159
t.Parallel()
160
node := harness.NewT(t).NewNode().Init().StartDaemon()
161
+ defer node.StopDaemon()
162
163
res := node.RunIPFS("pin", "remote", "service", "add", "svc", "invalid-service.example.com", "key")
164
assert.Equal(t, 1, res.ExitCode())
@@ -168,6 +172,7 @@ func TestRemotePinning(t *testing.T) {
172
t.Run("unauthorized pinning service calls fail", func(t *testing.T) {
173
t.Parallel()
174
node := harness.NewT(t).NewNode().Init().StartDaemon()
175
+ defer node.StopDaemon()
176
_, svcURL := runPinningService(t, authToken)
177
178
node.IPFS("pin", "remote", "service", "add", "svc", svcURL, "othertoken")
@@ -180,6 +185,7 @@ func TestRemotePinning(t *testing.T) {
185
t.Run("pinning service calls fail when there is a wrong path", func(t *testing.T) {
186
t.Parallel()
187
node := harness.NewT(t).NewNode().Init().StartDaemon()
188
+ defer node.StopDaemon()
189
_, svcURL := runPinningService(t, authToken)
190
node.IPFS("pin", "remote", "service", "add", "svc", svcURL+"/invalid-path", authToken)
191
@@ -191,6 +197,7 @@ func TestRemotePinning(t *testing.T) {
197
t.Run("pinning service calls fail when DNS resolution fails", func(t *testing.T) {
198
t.Parallel()
199
node := harness.NewT(t).NewNode().Init().StartDaemon()
200
+ defer node.StopDaemon()
201
node.IPFS("pin", "remote", "service", "add", "svc", "https://invalid-service.example.com", authToken)
202
203
res := node.RunIPFS("pin", "remote", "ls", "--service=svc")
@@ -201,6 +208,7 @@ func TestRemotePinning(t *testing.T) {
208
t.Run("pin remote service rm", func(t *testing.T) {
209
t.Parallel()
210
node := harness.NewT(t).NewNode().Init().StartDaemon()
211
+ defer node.StopDaemon()
212
node.IPFS("pin", "remote", "service", "add", "svc", "https://example.com", authToken)
213
node.IPFS("pin", "remote", "service", "rm", "svc")
214
res := node.IPFS("pin", "remote", "service", "ls")
@@ -225,6 +233,7 @@ func TestRemotePinning(t *testing.T) {
233
234
t.Run("'ipfs pin remote add --background=true'", func(t *testing.T) {
235
node := harness.NewT(t).NewNode().Init().StartDaemon()
236
+ defer node.StopDaemon()
237
svc, svcURL := runPinningService(t, authToken)
238
node.IPFS("pin", "remote", "service", "add", "svc", svcURL, authToken)
239
@@ -266,6 +275,7 @@ func TestRemotePinning(t *testing.T) {
275
t.Run("'ipfs pin remote add --background=false'", func(t *testing.T) {
276
t.Parallel()
277
node := harness.NewT(t).NewNode().Init().StartDaemon()
278
+ defer node.StopDaemon()
279
svc, svcURL := runPinningService(t, authToken)
280
node.IPFS("pin", "remote", "service", "add", "svc", svcURL, authToken)
281
@@ -287,6 +297,7 @@ func TestRemotePinning(t *testing.T) {
297
t.Run("'ipfs pin remote ls' with multiple statuses", func(t *testing.T) {
298
t.Parallel()
299
node := harness.NewT(t).NewNode().Init().StartDaemon()
300
+ defer node.StopDaemon()
301
svc, svcURL := runPinningService(t, authToken)
302
node.IPFS("pin", "remote", "service", "add", "svc", svcURL, authToken)
303
@@ -340,6 +351,7 @@ func TestRemotePinning(t *testing.T) {
351
t.Run("'ipfs pin remote ls' by CID", func(t *testing.T) {
352
t.Parallel()
353
node := harness.NewT(t).NewNode().Init().StartDaemon()
354
+ defer node.StopDaemon()
355
svc, svcURL := runPinningService(t, authToken)
356
node.IPFS("pin", "remote", "service", "add", "svc", svcURL, authToken)
357
@@ -360,6 +372,7 @@ func TestRemotePinning(t *testing.T) {
372
t.Run("'ipfs pin remote rm --name' without --force when multiple pins match", func(t *testing.T) {
373
t.Parallel()
374
node := harness.NewT(t).NewNode().Init().StartDaemon()
375
+ defer node.StopDaemon()
376
svc, svcURL := runPinningService(t, authToken)
377
node.IPFS("pin", "remote", "service", "add", "svc", svcURL, authToken)
378
@@ -388,6 +401,7 @@ func TestRemotePinning(t *testing.T) {
401
t.Run("'ipfs pin remote rm --name --force' remove multiple pins", func(t *testing.T) {
402
t.Parallel()
403
node := harness.NewT(t).NewNode().Init().StartDaemon()
404
+ defer node.StopDaemon()
405
svc, svcURL := runPinningService(t, authToken)
406
node.IPFS("pin", "remote", "service", "add", "svc", svcURL, authToken)
407
@@ -408,6 +422,7 @@ func TestRemotePinning(t *testing.T) {
422
t.Run("'ipfs pin remote rm --force' removes all pins", func(t *testing.T) {
423
t.Parallel()
424
node := harness.NewT(t).NewNode().Init().StartDaemon()
425
+ defer node.StopDaemon()
426
svc, svcURL := runPinningService(t, authToken)
427
node.IPFS("pin", "remote", "service", "add", "svc", svcURL, authToken)
428
test/cli/pins_test.go
+4
@@ -26,6 +26,7 @@ func testPins(t *testing.T, args testPinsArgs) {
26
node := harness.NewT(t).NewNode().Init()
27
if args.runDaemon {
28
node.StartDaemon("--offline")
29
+ defer node.StopDaemon()
30
}
31
32
strs := []string{"a", "b", "c", "d", "e", "f", "g"}
@@ -127,6 +128,7 @@ func testPinsErrorReporting(t *testing.T, args testPinsArgs) {
128
node := harness.NewT(t).NewNode().Init()
129
if args.runDaemon {
130
node.StartDaemon("--offline")
131
+ defer node.StopDaemon()
132
}
133
randomCID := "Qme8uX5n9hn15pw9p6WcVKoziyyC9LXv4LEgvsmKMULjnV"
134
res := node.RunIPFS(StrCat("pin", "add", args.pinArg, randomCID)...)
@@ -142,6 +144,7 @@ func testPinDAG(t *testing.T, args testPinsArgs) {
144
node := h.NewNode().Init()
145
if args.runDaemon {
146
node.StartDaemon("--offline")
147
+ defer node.StopDaemon()
148
}
149
bytes := random.Bytes(1 << 20) // 1 MiB
150
tmpFile := h.WriteToTemp(string(bytes))
@@ -168,6 +171,7 @@ func testPinProgress(t *testing.T, args testPinsArgs) {
171
172
if args.runDaemon {
173
node.StartDaemon("--offline")
174
+ defer node.StopDaemon()
175
}
176
177
bytes := random.Bytes(1 << 20) // 1 MiB
test/cli/rcmgr_test.go
+11
@@ -26,6 +26,7 @@ func TestRcmgr(t *testing.T) {
26
})
27
28
node.StartDaemon()
29
+ defer node.StopDaemon()
30
31
t.Run("swarm resources should fail", func(t *testing.T) {
32
res := node.RunIPFS("swarm", "resources")
@@ -41,6 +42,7 @@ func TestRcmgr(t *testing.T) {
42
cfg.Swarm.ResourceMgr.Enabled = config.False
43
})
44
node.StartDaemon()
45
+ defer node.StopDaemon()
46
47
t.Run("swarm resources should fail", func(t *testing.T) {
48
res := node.RunIPFS("swarm", "resources")
@@ -56,6 +58,7 @@ func TestRcmgr(t *testing.T) {
58
cfg.Swarm.ConnMgr.HighWater = config.NewOptionalInteger(1000)
59
})
60
node.StartDaemon()
61
+ defer node.StopDaemon()
62
63
res := node.RunIPFS("swarm", "resources", "--enc=json")
64
require.Equal(t, 0, res.ExitCode())
@@ -73,7 +76,9 @@ func TestRcmgr(t *testing.T) {
76
node.UpdateConfig(func(cfg *config.Config) {
77
cfg.Swarm.ConnMgr.HighWater = config.NewOptionalInteger(1000)
78
})
79
+
80
node.StartDaemon()
81
+ t.Cleanup(func() { node.StopDaemon() })
82
83
t.Run("conns and streams are above 800 for default connmgr settings", func(t *testing.T) {
84
t.Parallel()
@@ -135,6 +140,7 @@ func TestRcmgr(t *testing.T) {
140
overrides.System.ConnsInbound = rcmgr.Unlimited
141
})
142
node.StartDaemon()
143
+ defer node.StopDaemon()
144
145
res := node.RunIPFS("swarm", "resources", "--enc=json")
146
limits := unmarshalLimits(t, res.Stdout.Bytes())
@@ -150,6 +156,7 @@ func TestRcmgr(t *testing.T) {
156
overrides.Transient.Memory = 88888
157
})
158
node.StartDaemon()
159
+ defer node.StopDaemon()
160
161
res := node.RunIPFS("swarm", "resources", "--enc=json")
162
limits := unmarshalLimits(t, res.Stdout.Bytes())
@@ -163,6 +170,7 @@ func TestRcmgr(t *testing.T) {
170
overrides.Service = map[string]rcmgr.ResourceLimits{"foo": {Memory: 77777}}
171
})
172
node.StartDaemon()
173
+ defer node.StopDaemon()
174
175
res := node.RunIPFS("swarm", "resources", "--enc=json")
176
limits := unmarshalLimits(t, res.Stdout.Bytes())
@@ -176,6 +184,7 @@ func TestRcmgr(t *testing.T) {
184
overrides.Protocol = map[protocol.ID]rcmgr.ResourceLimits{"foo": {Memory: 66666}}
185
})
186
node.StartDaemon()
187
+ defer node.StopDaemon()
188
189
res := node.RunIPFS("swarm", "resources", "--enc=json")
190
limits := unmarshalLimits(t, res.Stdout.Bytes())
@@ -191,6 +200,7 @@ func TestRcmgr(t *testing.T) {
200
overrides.Peer = map[peer.ID]rcmgr.ResourceLimits{validPeerID: {Memory: 55555}}
201
})
202
node.StartDaemon()
203
+ defer node.StopDaemon()
204
205
res := node.RunIPFS("swarm", "resources", "--enc=json")
206
limits := unmarshalLimits(t, res.Stdout.Bytes())
@@ -218,6 +228,7 @@ func TestRcmgr(t *testing.T) {
228
})
229
230
nodes.StartDaemons()
231
+ t.Cleanup(func() { nodes.StopDaemons() })
232
233
t.Run("node 0 should fail to connect to and ping node 1", func(t *testing.T) {
234
t.Parallel()
test/cli/routing_dht_test.go
+2
@@ -57,6 +57,7 @@ func testRoutingDHT(t *testing.T, enablePubsub bool) {
57
}
58
59
nodes.StartDaemons(daemonArgs...).Connect()
60
+ t.Cleanup(func() { nodes.StopDaemons() })
61
62
t.Run("ipfs routing findpeer", func(t *testing.T) {
63
t.Parallel()
@@ -157,6 +158,7 @@ func testSelfFindDHT(t *testing.T) {
158
})
159
160
nodes.StartDaemons()
161
+ defer nodes.StopDaemons()
162
163
res := nodes[0].RunIPFS("dht", "findpeer", nodes[0].PeerID().String())
164
assert.Equal(t, 1, res.ExitCode())
test/cli/stats_test.go
+1
@@ -14,6 +14,7 @@ func TestStats(t *testing.T) {
14
t.Run("stats dht", func(t *testing.T) {
15
t.Parallel()
16
nodes := harness.NewT(t).NewNodes(2).Init().StartDaemons().Connect()
17
+ defer nodes.StopDaemons()
18
node1 := nodes[0]
19
20
res := node1.IPFS("stats", "dht")
test/cli/swarm_test.go
+5
@@ -31,6 +31,7 @@ func TestSwarm(t *testing.T) {
31
t.Run("ipfs swarm peers returns empty peers when a node is not connected to any peers", func(t *testing.T) {
32
t.Parallel()
33
node := harness.NewT(t).NewNode().Init().StartDaemon()
34
+ defer node.StopDaemon()
35
res := node.RunIPFS("swarm", "peers", "--enc=json", "--identify")
36
var output expectedOutputType
37
err := json.Unmarshal(res.Stdout.Bytes(), &output)
@@ -40,7 +41,9 @@ func TestSwarm(t *testing.T) {
41
t.Run("ipfs swarm peers with flag identify outputs expected identify information about connected peers", func(t *testing.T) {
42
t.Parallel()
43
node := harness.NewT(t).NewNode().Init().StartDaemon()
44
+ defer node.StopDaemon()
45
otherNode := harness.NewT(t).NewNode().Init().StartDaemon()
46
+ defer otherNode.StopDaemon()
47
node.Connect(otherNode)
48
49
res := node.RunIPFS("swarm", "peers", "--enc=json", "--identify")
@@ -67,7 +70,9 @@ func TestSwarm(t *testing.T) {
70
t.Run("ipfs swarm peers with flag identify outputs Identify field with data that matches calling ipfs id on a peer", func(t *testing.T) {
71
t.Parallel()
72
node := harness.NewT(t).NewNode().Init().StartDaemon()
73
+ defer node.StopDaemon()
74
otherNode := harness.NewT(t).NewNode().Init().StartDaemon()
75
+ defer otherNode.StopDaemon()
76
node.Connect(otherNode)
77
78
otherNodeIDResponse := otherNode.RunIPFS("id", "--enc=json")
test/cli/tracing_test.go
+1
@@ -76,6 +76,7 @@ func TestTracing(t *testing.T) {
76
node.Runner.Env["OTEL_EXPORTER_OTLP_PROTOCOL"] = "grpc"
77
node.Runner.Env["OTEL_EXPORTER_OTLP_ENDPOINT"] = "http://localhost:4317"
78
node.StartDaemon()
79
+ defer node.StopDaemon()
80
81
assert.Eventually(t,
82
func() bool {
test/cli/transports_test.go
+6
@@ -74,6 +74,7 @@ func TestTransports(t *testing.T) {
74
t.Parallel()
75
nodes := tcpNodes(t).StartDaemons().Connect()
76
runTests(nodes)
77
+ nodes.StopDaemons()
78
})
79
80
t.Run("tcp with NOISE", func(t *testing.T) {
@@ -86,6 +87,7 @@ func TestTransports(t *testing.T) {
87
})
88
nodes.StartDaemons().Connect()
89
runTests(nodes)
90
+ nodes.StopDaemons()
91
})
92
93
t.Run("QUIC", func(t *testing.T) {
@@ -104,6 +106,7 @@ func TestTransports(t *testing.T) {
106
disableRouting(nodes)
107
nodes.StartDaemons().Connect()
108
runTests(nodes)
109
+ nodes.StopDaemons()
110
})
111
112
t.Run("QUIC+Webtransport", func(t *testing.T) {
@@ -122,6 +125,7 @@ func TestTransports(t *testing.T) {
125
disableRouting(nodes)
126
nodes.StartDaemons().Connect()
127
runTests(nodes)
128
+ nodes.StopDaemons()
129
})
130
131
t.Run("QUIC connects with non-dialable transports", func(t *testing.T) {
@@ -144,6 +148,7 @@ func TestTransports(t *testing.T) {
148
disableRouting(nodes)
149
nodes.StartDaemons().Connect()
150
runTests(nodes)
151
+ nodes.StopDaemons()
152
})
153
154
t.Run("WebRTC Direct", func(t *testing.T) {
@@ -162,5 +167,6 @@ func TestTransports(t *testing.T) {
167
disableRouting(nodes)
168
nodes.StartDaemons().Connect()
169
runTests(nodes)
170
+ nodes.StopDaemons()
171
})
172
}