test(l4proxy): add unit tests for Handle (the proxy main loop)#435
Open
tannevaled wants to merge 1 commit into
Open
test(l4proxy): add unit tests for Handle (the proxy main loop)#435tannevaled wants to merge 1 commit into
tannevaled wants to merge 1 commit into
Conversation
Handle had no direct unit coverage; its behavior was only exercised indirectly through integration tests. This adds focused unit tests using the existing net.Pipe downstream pattern plus a real loopback echo upstream, bringing Handle to 100% statement coverage: - no upstream available + no retry -> returns 'no upstreams available' - selected upstream unreachable + no retry -> returns the dial error - no upstream available + retry enabled -> loops via tryAgain, then returns once TryDuration elapses - selected upstream unreachable + retry enabled -> dial-failure retry loop, then returns the error - success path -> selects, dials, proxies bytes both ways, returns nil after the downstream closes All pass under -race. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Handler.Handle— the core proxy loop inmodules/l4proxy— had no direct unit tests; its behavior was only exercised indirectly via integration tests. This PR adds focused unit tests that bringHandleto 100% statement coverage.Tests added
Using the existing
net.Pipedownstream pattern (already used by thedialPeerstests) plus a real loopback echo upstream:no upstreams available.tryAgain, then returns onceTryDurationelapses.continuebranch, then returns the error.nilafter the downstream connection closes.A small
newHandleTestConnhelper pairs an in-memory client end with alayer4.Connectionwrapping the server end.Verification
Handlegoes from 0% → 100% statement coverage. No production code changes.