mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
5a66807989
* First take at updating everything to v5 * Patch gRPC gateway to use prysm v5 Fix patch * Update go ssz --------- Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package client
|
|
|
|
import (
|
|
"net/url"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
|
)
|
|
|
|
func TestValidHostname(t *testing.T) {
|
|
cases := []struct {
|
|
name string
|
|
hostArg string
|
|
path string
|
|
joined string
|
|
err error
|
|
}{
|
|
{
|
|
name: "hostname without port",
|
|
hostArg: "mydomain.org",
|
|
err: ErrMalformedHostname,
|
|
},
|
|
}
|
|
for _, c := range cases {
|
|
t.Run(c.name, func(t *testing.T) {
|
|
cl, err := NewClient(c.hostArg)
|
|
if c.err != nil {
|
|
require.ErrorIs(t, err, c.err)
|
|
return
|
|
}
|
|
require.NoError(t, err)
|
|
require.Equal(t, c.joined, cl.BaseURL().ResolveReference(&url.URL{Path: c.path}).String())
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestWithAuthenticationToken(t *testing.T) {
|
|
cl, err := NewClient("https://www.offchainlabs.com:3500", WithAuthenticationToken("my token"))
|
|
require.NoError(t, err)
|
|
require.Equal(t, cl.Token(), "my token")
|
|
}
|
|
|
|
func TestBaseURL(t *testing.T) {
|
|
cl, err := NewClient("https://www.offchainlabs.com:3500")
|
|
require.NoError(t, err)
|
|
require.Equal(t, "www.offchainlabs.com", cl.BaseURL().Hostname())
|
|
require.Equal(t, "3500", cl.BaseURL().Port())
|
|
}
|