Skip to content
Merged
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
6 changes: 4 additions & 2 deletions internal/testutils/servers/bufconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ var globalBufconnRegistry = &bufconnRegistry{
dialers: make(map[testing.TB]bufconnDialer),
}

// nextAddress generates a unique fake address for a bufconn listener.
// nextAddress generates a fake address for a bufconn listener. The port wraps
// around within the valid range, so a long -count run does not overflow it;
// addresses only need to be distinct among the listeners alive at once.
func (r *bufconnRegistry) nextAddress() string {
port := r.portCounter.Add(1)
port := r.portCounter.Add(1) % (65536 - 10000)
return fmt.Sprintf("127.0.0.1:%d", 10000+port)
}

Expand Down
Loading