Skip to content

Commit 9f9c6f5

Browse files
authored
Merge pull request #2915 from ixje/feat-endpoint
rpcclient: expose endpoint (fixes #2912)
2 parents 1d6e48e + 3bdb3a8 commit 9f9c6f5

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

pkg/rpcclient/client.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,8 @@ func (c *Client) Ping() error {
255255
func (c *Client) Context() context.Context {
256256
return c.ctx
257257
}
258+
259+
// Endpoint returns the client endpoint.
260+
func (c *Client) Endpoint() string {
261+
return c.endpoint.String()
262+
}

pkg/rpcclient/client_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package rpcclient
2+
3+
import (
4+
"net/url"
5+
"testing"
6+
7+
"github.com/stretchr/testify/require"
8+
)
9+
10+
func TestGetEndpoint(t *testing.T) {
11+
host := "http://localhost:1234"
12+
u, err := url.Parse(host)
13+
require.NoError(t, err)
14+
client := Client{
15+
endpoint: u,
16+
}
17+
require.Equal(t, host, client.Endpoint())
18+
}

0 commit comments

Comments
 (0)