Commit e7a72c58 authored by Joshua Gutow's avatar Joshua Gutow

Fix test

parent 671917cd
......@@ -18,7 +18,7 @@ import (
// DefaultDialTimeout is a default timeout for dialing a client.
const DefaultDialTimeout = 30 * time.Second
const defaultRetryCount = 30
const defaultRetryTime = 1 * time.Second
const defaultRetryTime = 1_500 * time.Millisecond
// DialEthClientWithTimeout attempts to dial the L1 provider using the provided
// URL. If the dial doesn't complete within defaultDialTimeout seconds, this
......
package client
import (
"net/http"
"fmt"
"net"
"strings"
"testing"
"github.com/stretchr/testify/require"
)
func TestIsURLAvailable(t *testing.T) {
go func() {
_ = http.ListenAndServe(":8989", nil)
}()
listener, err := net.Listen("tcp4", ":0")
require.NoError(t, err)
defer listener.Close()
require.True(t, IsURLAvailable("http://localhost:8989"))
require.False(t, IsURLAvailable("http://localhost:9898"))
a := listener.Addr().String()
parts := strings.Split(a, ":")
addr := fmt.Sprintf("http://localhost:%s", parts[1])
require.True(t, IsURLAvailable(addr))
require.False(t, IsURLAvailable("http://localhost:0"))
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment