forked from cerc-io/plugeth
cmd/geth: fix IPC probe in les test (#23094)
Previously, the test waited a second and then failed if geth had not started. This caused the test to fail intermittently. This change checks whether the IPC is open 10 times over a 5 second period and then fails if geth is still not available.
This commit is contained in:
parent
948a600ed5
commit
0e6961366a
@ -137,14 +137,18 @@ func startGethWithIpc(t *testing.T, name string, args ...string) *gethrpc {
|
|||||||
name: name,
|
name: name,
|
||||||
geth: runGeth(t, args...),
|
geth: runGeth(t, args...),
|
||||||
}
|
}
|
||||||
// wait before we can attach to it. TODO: probe for it properly
|
|
||||||
time.Sleep(1 * time.Second)
|
|
||||||
var err error
|
|
||||||
ipcpath := ipcEndpoint(ipcName, g.geth.Datadir)
|
ipcpath := ipcEndpoint(ipcName, g.geth.Datadir)
|
||||||
if g.rpc, err = rpc.Dial(ipcpath); err != nil {
|
// We can't know exactly how long geth will take to start, so we try 10
|
||||||
t.Fatalf("%v rpc connect to %v: %v", name, ipcpath, err)
|
// times over a 5 second period.
|
||||||
|
var err error
|
||||||
|
for i := 0; i < 10; i++ {
|
||||||
|
time.Sleep(500 * time.Millisecond)
|
||||||
|
if g.rpc, err = rpc.Dial(ipcpath); err == nil {
|
||||||
|
return g
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return g
|
t.Fatalf("%v rpc connect to %v: %v", name, ipcpath, err)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func initGeth(t *testing.T) string {
|
func initGeth(t *testing.T) string {
|
||||||
|
Loading…
Reference in New Issue
Block a user