Skip to content

Commit

Permalink
consensus/ethash: wait for listener to start listening
Browse files Browse the repository at this point in the history
  • Loading branch information
nonsense committed Aug 28, 2018
1 parent 672de17 commit 6834fd7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions consensus/ethash/sealer_test.go
Expand Up @@ -40,6 +40,18 @@ func TestRemoteNotify(t *testing.T) {

go server.Serve(listener)

// Wait for server to start listening
var tries int
for tries = 0; tries < 10; tries++ {
conn, _ := net.DialTimeout("tcp", listener.Addr().String(), 1*time.Second)
if conn != nil {
break
}
}
if tries == 10 {
t.Fatal("tcp listener not ready for more than 10 seconds")
}

// Create the custom ethash engine
ethash := NewTester([]string{"http://" + listener.Addr().String()})
defer ethash.Close()
Expand Down

0 comments on commit 6834fd7

Please sign in to comment.