Skip to content

Commit 433937f

Browse files
gballetfjl
authored andcommitted
cmd/geth: fix forked exe leak in console tests (#20480)
1 parent 2eeb8dd commit 433937f

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

‎cmd/geth/consolecmd_test.go‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,14 @@ func TestIPCAttachWelcome(t *testing.T) {
8787
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
8888
"--etherbase", coinbase, "--shh", "--ipcpath", ipc)
8989

90+
defer func() {
91+
geth.Interrupt()
92+
geth.ExpectExit()
93+
}()
94+
9095
waitForEndpoint(t, ipc, 3*time.Second)
9196
testAttachWelcome(t, geth, "ipc:"+ipc, ipcAPIs)
9297

93-
geth.Interrupt()
94-
geth.ExpectExit()
9598
}
9699

97100
func TestHTTPAttachWelcome(t *testing.T) {
@@ -100,13 +103,14 @@ func TestHTTPAttachWelcome(t *testing.T) {
100103
geth := runGeth(t,
101104
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
102105
"--etherbase", coinbase, "--rpc", "--rpcport", port)
106+
defer func() {
107+
geth.Interrupt()
108+
geth.ExpectExit()
109+
}()
103110

104111
endpoint := "http://127.0.0.1:" + port
105112
waitForEndpoint(t, endpoint, 3*time.Second)
106113
testAttachWelcome(t, geth, endpoint, httpAPIs)
107-
108-
geth.Interrupt()
109-
geth.ExpectExit()
110114
}
111115

112116
func TestWSAttachWelcome(t *testing.T) {
@@ -116,13 +120,14 @@ func TestWSAttachWelcome(t *testing.T) {
116120
geth := runGeth(t,
117121
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
118122
"--etherbase", coinbase, "--ws", "--wsport", port)
123+
defer func() {
124+
geth.Interrupt()
125+
geth.ExpectExit()
126+
}()
119127

120128
endpoint := "ws://127.0.0.1:" + port
121129
waitForEndpoint(t, endpoint, 3*time.Second)
122130
testAttachWelcome(t, geth, endpoint, httpAPIs)
123-
124-
geth.Interrupt()
125-
geth.ExpectExit()
126131
}
127132

128133
func testAttachWelcome(t *testing.T, geth *testgeth, endpoint, apis string) {

0 commit comments

Comments
 (0)