• Filippo Valsorda's avatar
    crypto/tls: replace net.Pipe in tests with real TCP connections · be0f3c28
    Filippo Valsorda authored
    crypto/tls is meant to work over network connections with buffering, not
    synchronous connections, as explained in #24198. Tests based on net.Pipe
    are unrealistic as reads and writes are matched one to one. Such tests
    worked just thanks to the implementation details of the tls.Conn
    internal buffering, and would break if for example the flush of the
    first flight of the server was not entirely assimilated by the client
    rawInput buffer before the client attempted to reply to the ServerHello.
    
    Note that this might run into the Darwin network issues at #25696.
    
    Fixed a few test races that were either hidden or synchronized by the
    use of the in-memory net.Pipe.
    
    Also, this gets us slightly more realistic benchmarks, reflecting some
    syscall cost of Read and Write operations.
    
    Change-Id: I5a597b3d7a81b8ccc776030cc837133412bf50f8
    Reviewed-on: https://go-review.googlesource.com/c/142817
    Run-TryBot: Filippo Valsorda <filippo@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    be0f3c28
conn_test.go 10.5 KB