Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

feat: Durability test RTC connections #329

Merged
merged 19 commits into from
May 3, 2021
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add disconnect err test
  • Loading branch information
kylecarbs committed May 3, 2021
commit e2456e86313989e75660afa74887d1d3971344b9
26 changes: 12 additions & 14 deletions wsnet/dial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package wsnet
import (
"context"
"errors"
"fmt"
"io"
"testing"

"github.com/pion/webrtc/v3"
Expand Down Expand Up @@ -57,32 +57,30 @@ func TestDial(t *testing.T) {
if err != nil {
t.Error(err)
}

})

t.Run("Pipe", func(t *testing.T) {
t.Run("Disconnect", func(t *testing.T) {
connectAddr, listenAddr := createDumbBroker(t)
listener, err := Listen(context.Background(), listenAddr)
if err != nil {
t.Error(err)
}
go func() {
c, _ := listener.Accept()
c.Close()
}()
dialer, err := Dial(context.Background(), connectAddr, nil)
if err != nil {
t.Error(err)
}
go func() {
conn, err := dialer.DialContext(context.Background(), "tcp", "localhost:40000")
if err != nil {
t.Error(err)
}
conn.Write([]byte("hello"))
}()
conn, err := listener.Accept()
conn, err := dialer.DialContext(context.Background(), "tcp", "example")
if err != nil {
t.Error(err)
}
b := make([]byte, 5)
_, _ = conn.Read(b)
fmt.Printf("WE LEGIT GOT IT! %s\n", b)
b := make([]byte, 16)
_, err = conn.Read(b)
if err != io.EOF {
t.Error(err)
}
})
}