Skip to content

Commit

Permalink
Merge pull request nspcc-dev#2915 from ixje/feat-endpoint
Browse files Browse the repository at this point in the history
rpcclient: expose endpoint (fixes nspcc-dev#2912)
  • Loading branch information
roman-khimov committed Feb 15, 2023
2 parents 1d6e48e + 3bdb3a8 commit 9f9c6f5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/rpcclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
18 changes: 18 additions & 0 deletions pkg/rpcclient/client_test.go
Original file line number Diff line number Diff line change
@@ -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())
}

0 comments on commit 9f9c6f5

Please sign in to comment.