Commit e7a72c58 authored by Joshua Gutow's avatar Joshua Gutow

Fix test

parent 671917cd
...@@ -18,7 +18,7 @@ import ( ...@@ -18,7 +18,7 @@ import (
// DefaultDialTimeout is a default timeout for dialing a client. // DefaultDialTimeout is a default timeout for dialing a client.
const DefaultDialTimeout = 30 * time.Second const DefaultDialTimeout = 30 * time.Second
const defaultRetryCount = 30 const defaultRetryCount = 30
const defaultRetryTime = 1 * time.Second const defaultRetryTime = 1_500 * time.Millisecond
// DialEthClientWithTimeout attempts to dial the L1 provider using the provided // DialEthClientWithTimeout attempts to dial the L1 provider using the provided
// URL. If the dial doesn't complete within defaultDialTimeout seconds, this // URL. If the dial doesn't complete within defaultDialTimeout seconds, this
......
package client package client
import ( import (
"net/http" "fmt"
"net"
"strings"
"testing" "testing"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
func TestIsURLAvailable(t *testing.T) { func TestIsURLAvailable(t *testing.T) {
go func() { listener, err := net.Listen("tcp4", ":0")
_ = http.ListenAndServe(":8989", nil) require.NoError(t, err)
}() defer listener.Close()
require.True(t, IsURLAvailable("http://localhost:8989")) a := listener.Addr().String()
require.False(t, IsURLAvailable("http://localhost:9898")) 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