Skip to content

Commit

Permalink
Update client.go to allow the use of paths with the heimdall url (#1126)
Browse files Browse the repository at this point in the history
* Update client.go to allow the use of paths with the heimdall url

As reported to the polygon team 2 months ago in the Ankr polygon slack, the current code prevents the use of a path with the heimdall url, this was fixed in erigon erigontech/erigon@a3a6170 in response to my request by Mark Holt, and it seems this code was just copied from bor where it is incorrect too. This patch fixes that.

* Add reference to path library

* Fix reversed order of values in unit tests and test removal of setting u.path to rawPath (otherwise why do we need rawPath at all) seems like there were work arounds done here in bioth the unit tests AND the makeURL but logic needs to be examined
  • Loading branch information
PeaStew authored Jan 15, 2024
1 parent 70bebc9 commit dac1a42
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion consensus/bor/heimdall/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"net/http"
"net/url"
"path"
"sort"
"time"

Expand Down Expand Up @@ -420,7 +421,7 @@ func makeURL(urlString, rawPath, rawQuery string) (*url.URL, error) {
return nil, err
}

u.Path = rawPath
u.Path = path.Join(u.Path, rawPath)
u.RawQuery = rawQuery

return u, err
Expand Down
4 changes: 2 additions & 2 deletions consensus/bor/heimdall/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ func TestSpanURL(t *testing.T) {
const expected = "http://bor0/bor/span/1"

if url.String() != expected {
t.Fatalf("expected URL %q, got %q", url.String(), expected)
t.Fatalf("expected URL %q, got %q", expected, url.String())
}
}

Expand All @@ -414,6 +414,6 @@ func TestStateSyncURL(t *testing.T) {
const expected = "http://bor0/clerk/event-record/list?from-id=10&to-time=100&limit=50"

if url.String() != expected {
t.Fatalf("expected URL %q, got %q", url.String(), expected)
t.Fatalf("expected URL %q, got %q", expected, url.String())
}
}

0 comments on commit dac1a42

Please sign in to comment.