mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
cmd/geth, internal: fix flaky console tests
This commit is contained in:
parent
0d5de826da
commit
032ef0e84c
3 changed files with 5 additions and 5 deletions
|
|
@ -102,17 +102,17 @@ func TestAttachWelcome(t *testing.T) {
|
||||||
"--http", "--http.port", httpPort,
|
"--http", "--http.port", httpPort,
|
||||||
"--ws", "--ws.port", wsPort)
|
"--ws", "--ws.port", wsPort)
|
||||||
t.Run("ipc", func(t *testing.T) {
|
t.Run("ipc", func(t *testing.T) {
|
||||||
waitForEndpoint(t, ipc, 4*time.Second)
|
waitForEndpoint(t, ipc, 2*time.Minute)
|
||||||
testAttachWelcome(t, geth, "ipc:"+ipc, ipcAPIs)
|
testAttachWelcome(t, geth, "ipc:"+ipc, ipcAPIs)
|
||||||
})
|
})
|
||||||
t.Run("http", func(t *testing.T) {
|
t.Run("http", func(t *testing.T) {
|
||||||
endpoint := "http://127.0.0.1:" + httpPort
|
endpoint := "http://127.0.0.1:" + httpPort
|
||||||
waitForEndpoint(t, endpoint, 4*time.Second)
|
waitForEndpoint(t, endpoint, 2*time.Minute)
|
||||||
testAttachWelcome(t, geth, endpoint, httpAPIs)
|
testAttachWelcome(t, geth, endpoint, httpAPIs)
|
||||||
})
|
})
|
||||||
t.Run("ws", func(t *testing.T) {
|
t.Run("ws", func(t *testing.T) {
|
||||||
endpoint := "ws://127.0.0.1:" + wsPort
|
endpoint := "ws://127.0.0.1:" + wsPort
|
||||||
waitForEndpoint(t, endpoint, 4*time.Second)
|
waitForEndpoint(t, endpoint, 2*time.Minute)
|
||||||
testAttachWelcome(t, geth, endpoint, httpAPIs)
|
testAttachWelcome(t, geth, endpoint, httpAPIs)
|
||||||
})
|
})
|
||||||
geth.Kill()
|
geth.Kill()
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ func runGeth(t *testing.T, args ...string) *testgeth {
|
||||||
// waitForEndpoint attempts to connect to an RPC endpoint until it succeeds.
|
// waitForEndpoint attempts to connect to an RPC endpoint until it succeeds.
|
||||||
func waitForEndpoint(t *testing.T, endpoint string, timeout time.Duration) {
|
func waitForEndpoint(t *testing.T, endpoint string, timeout time.Duration) {
|
||||||
probe := func() bool {
|
probe := func() bool {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
c, err := rpc.DialContext(ctx, endpoint)
|
c, err := rpc.DialContext(ctx, endpoint)
|
||||||
if c != nil {
|
if c != nil {
|
||||||
|
|
|
||||||
|
|
@ -237,7 +237,7 @@ func (tt *TestCmd) Kill() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tt *TestCmd) withKillTimeout(fn func()) {
|
func (tt *TestCmd) withKillTimeout(fn func()) {
|
||||||
timeout := time.AfterFunc(30*time.Second, func() {
|
timeout := time.AfterFunc(2*time.Minute, func() {
|
||||||
tt.Log("killing the child process (timeout)")
|
tt.Log("killing the child process (timeout)")
|
||||||
tt.Kill()
|
tt.Kill()
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue