Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/rpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ func (c *Client) heightIdAndPointsRequest(routeName string, height, id uint64, p

func (c *Client) url(routeName, param string, admin ...bool) string {
// if an admin call
if admin != nil && admin[0] {
if len(admin) > 0 && admin[0] {
return c.adminRpcUrl + routePaths[routeName].Path + param
}
// if non admin call
Expand Down
24 changes: 24 additions & 0 deletions cmd/rpc/client_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package rpc

import "testing"

func TestClientURLEmptyAdminFlag(t *testing.T) {
client := NewClient("http://query", "http://admin")
emptyAdmin := []bool{}

got := client.url(LogsRouteName, "", emptyAdmin...)
want := "http://query" + routePaths[LogsRouteName].Path
if got != want {
t.Fatalf("url with empty admin flag = %q, want %q", got, want)
}
}

func TestClientURLAdminFlag(t *testing.T) {
client := NewClient("http://query", "http://admin")

got := client.url(LogsRouteName, "", true)
want := "http://admin" + routePaths[LogsRouteName].Path
if got != want {
t.Fatalf("url with admin flag = %q, want %q", got, want)
}
}