diff --git a/pkg/rpcclient/client.go b/pkg/rpcclient/client.go index bd35073d8..67cf3f10d 100644 --- a/pkg/rpcclient/client.go +++ b/pkg/rpcclient/client.go @@ -255,3 +255,8 @@ func (c *Client) Ping() error { func (c *Client) Context() context.Context { return c.ctx } + +// Endpoint returns the client endpoint. +func (c *Client) Endpoint() string { + return c.endpoint.String() +} diff --git a/pkg/rpcclient/client_test.go b/pkg/rpcclient/client_test.go new file mode 100644 index 000000000..26038eb27 --- /dev/null +++ b/pkg/rpcclient/client_test.go @@ -0,0 +1,18 @@ +package rpcclient + +import ( + "net/url" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestGetEndpoint(t *testing.T) { + host := "http://localhost:1234" + u, err := url.Parse(host) + require.NoError(t, err) + client := Client{ + endpoint: u, + } + require.Equal(t, host, client.Endpoint()) +}