Skip to content

Commit

Permalink
debug test
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt committed Aug 23, 2024
1 parent 273d2b4 commit 276b891
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ func TestSendData_Large(t *testing.T) {
}
}

func testTCPConns(t *testing.T) (*Session, *Session) {
func testTCPConns(t *testing.T) (net.Conn, net.Conn) {
ln, err := net.ListenTCP("tcp", &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 0})
if err != nil {
t.Fatal(err)
Expand All @@ -649,9 +649,7 @@ func testTCPConns(t *testing.T) (*Session, *Session) {
return nil, nil
}

client, _ := Client(clientConn, testConf(), nil)
server, _ := Server(<-serverConnCh, testConf(), nil)
return client, server
return clientConn, <-serverConnCh

}

Expand All @@ -660,7 +658,9 @@ func TestGoAway(t *testing.T) {
conf := testConf()
conf.LogOutput = io.Discard

client, server := testTCPConns(t)
clientConn, serverConn := testTCPConns(t)
client, _ := Client(clientConn, testConf(), nil)
server, _ := Server(serverConn, testConf(), nil)
defer client.Close()
defer server.Close()

Expand Down Expand Up @@ -1821,3 +1821,28 @@ func TestMaxIncomingStreams(t *testing.T) {
_, err = str.Read([]byte{0})
require.NoError(t, err)
}

func TestRSTBehavior(t *testing.T) {
client, server := testTCPConns(t)
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
defer server.Close()
server.Write([]byte("hello"))
time.Sleep(20 * time.Second)
buf := make([]byte, 10)
n, err := server.Read(buf)
if err != nil {
t.Error(err)
} else {
t.Log(string(buf[:n]))
}

}()
client.Write([]byte("world"))
time.Sleep(10 * time.Second)
// close client without reading server msg. This ensures that the TCP stack sends an RST
client.Close()
wg.Wait()
}

0 comments on commit 276b891

Please sign in to comment.