-
Notifications
You must be signed in to change notification settings - Fork 3
fix(devnet): quiet status-registry probes and bump evm-upgrade to v1.20.2 #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f6514bb
fix(devnet): quiet status-registry probes and bump evm-upgrade to v1.…
akobrin1 545f7c6
fix(ci): address PR 209 review and test flakes
akobrin1 bc2efb9
Merge remote-tracking branch 'origin/master' into fix/devnet-evmigrat…
akobrin1 2942b48
fix(jsonrpc): keep derived upstream ports unprivileged
akobrin1 69f8c15
fix(jsonrpc): probe unprivileged upstream fallbacks
akobrin1 1edc728
test(cmd): serialize SDK global mutations
akobrin1 8e41d46
fix(jsonrpc): avoid configured listener ports
akobrin1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "net" | ||
| "strconv" | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestLoopbackAddrForPublicIsStableAndUnique(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| tests := []struct { | ||
| public string | ||
| want string | ||
| }{ | ||
| {public: "127.0.0.1:8545", want: "127.0.0.1:42336"}, | ||
| {public: "0.0.0.0:8645", want: "127.0.0.1:42436"}, | ||
| {public: "[::]:8745", want: "127.0.0.1:42536"}, | ||
| {public: "localhost:32768", want: "127.0.0.1:2047"}, | ||
| {public: "127.0.0.1:32863", want: "127.0.0.1:2142"}, | ||
| } | ||
|
|
||
| seen := make(map[string]string, len(tests)) | ||
| for _, tc := range tests { | ||
| t.Run(tc.public, func(t *testing.T) { | ||
| got, err := loopbackAddrForPublic(tc.public) | ||
| if err != nil { | ||
| t.Fatalf("loopbackAddrForPublic(%q): %v", tc.public, err) | ||
| } | ||
| if got != tc.want { | ||
| t.Fatalf("loopbackAddrForPublic(%q) = %q, want %q", tc.public, got, tc.want) | ||
| } | ||
| if previous, exists := seen[got]; exists { | ||
| t.Fatalf("public addresses %q and %q mapped to the same internal address %q", previous, tc.public, got) | ||
| } | ||
| seen[got] = tc.public | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestLoopbackAddrForPublicRejectsInvalidAddress(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| for _, publicAddr := range []string{"", "127.0.0.1", "127.0.0.1:0", "127.0.0.1:65536"} { | ||
| if _, err := loopbackAddrForPublic(publicAddr); err == nil { | ||
| t.Fatalf("loopbackAddrForPublic(%q) unexpectedly succeeded", publicAddr) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func TestReserveLoopbackAddrFallsBackWhenPrimaryIsOccupied(t *testing.T) { | ||
| occupied, err := net.Listen("tcp", "127.0.0.1:0") | ||
| if err != nil { | ||
| t.Fatalf("listen on occupied primary: %v", err) | ||
| } | ||
| t.Cleanup(func() { _ = occupied.Close() }) | ||
|
|
||
| occupiedPort := occupied.Addr().(*net.TCPAddr).Port | ||
| publicAddr := publicAddrForInternalPort(t, occupiedPort) | ||
| got, err := reserveLoopbackAddr(publicAddr) | ||
| if err != nil { | ||
| t.Fatalf("reserveLoopbackAddr(%q): %v", publicAddr, err) | ||
| } | ||
| if got == occupied.Addr().String() { | ||
| t.Fatalf("reserveLoopbackAddr(%q) returned occupied primary %q", publicAddr, got) | ||
| } | ||
|
|
||
| _, portText, err := net.SplitHostPort(got) | ||
| if err != nil { | ||
| t.Fatalf("parse fallback address %q: %v", got, err) | ||
| } | ||
| port, err := strconv.Atoi(portText) | ||
| if err != nil || port < firstUnprivilegedPort || port > lastUnprivilegedPort { | ||
| t.Fatalf("fallback address %q is not unprivileged", got) | ||
| } | ||
|
|
||
| probe, err := net.Listen("tcp", got) | ||
| if err != nil { | ||
| t.Fatalf("fallback address %q is not available: %v", got, err) | ||
| } | ||
| _ = probe.Close() | ||
| } | ||
|
|
||
| func TestReserveLoopbackAddrSkipsLaterListenerPorts(t *testing.T) { | ||
| const publicAddr = "0.0.0.0:39267" // primary candidate is default WS port 8546 | ||
| primary, err := loopbackAddrForPublic(publicAddr) | ||
| if err != nil { | ||
| t.Fatalf("loopbackAddrForPublic(%q): %v", publicAddr, err) | ||
| } | ||
| if primary != "127.0.0.1:8546" { | ||
| t.Fatalf("test precondition: primary = %q, want default WS address", primary) | ||
| } | ||
|
|
||
| for _, excludedAddr := range []string{ | ||
| "127.0.0.1:8546", | ||
| "tcp://127.0.0.1:8546", | ||
| } { | ||
| t.Run(excludedAddr, func(t *testing.T) { | ||
| got, err := reserveLoopbackAddr(publicAddr, excludedAddr) | ||
| if err != nil { | ||
| t.Fatalf("reserveLoopbackAddr(%q): %v", publicAddr, err) | ||
| } | ||
| if got == "127.0.0.1:8546" { | ||
| t.Fatalf("reserveLoopbackAddr(%q) selected excluded listener %q", publicAddr, got) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func publicAddrForInternalPort(t *testing.T, internalPort int) string { | ||
| t.Helper() | ||
|
|
||
| want := net.JoinHostPort("127.0.0.1", strconv.Itoa(internalPort)) | ||
| for publicPort := firstUnprivilegedPort; publicPort <= lastUnprivilegedPort; publicPort++ { | ||
| publicAddr := net.JoinHostPort("127.0.0.1", strconv.Itoa(publicPort)) | ||
| got, err := loopbackAddrForPublic(publicAddr) | ||
| if err != nil { | ||
| t.Fatalf("loopbackAddrForPublic(%q): %v", publicAddr, err) | ||
| } | ||
| if got == want { | ||
| return publicAddr | ||
| } | ||
| } | ||
|
|
||
| t.Fatalf("no public port maps to internal port %d", internalPort) | ||
| return "" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.