Skip to content

Commit

Permalink
Consume net package in tests
Browse files Browse the repository at this point in the history
Updates unit and e2e tests to consume new utilities from the dtls net
package.

Signed-off-by: Daniel Mangum <[email protected]>
  • Loading branch information
hasheddan committed Aug 27, 2023
1 parent 4f53ce1 commit 703da0c
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 67 deletions.
10 changes: 5 additions & 5 deletions bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"testing"
"time"

"github.com/pion/dtls/v2/internal/util"
"github.com/pion/dtls/v2/pkg/crypto/selfsign"
dtlsnet "github.com/pion/dtls/v2/pkg/net"
"github.com/pion/logging"
"github.com/pion/transport/v2/dpipe"
"github.com/pion/transport/v2/test"
Expand All @@ -31,7 +31,7 @@ func TestSimpleReadWrite(t *testing.T) {
gotHello := make(chan struct{})

go func() {
server, sErr := testServer(ctx, util.FromConn(cb), cb.RemoteAddr(), &Config{
server, sErr := testServer(ctx, dtlsnet.PacketConnFromConn(cb), cb.RemoteAddr(), &Config{
Certificates: []tls.Certificate{certificate},
LoggerFactory: logging.NewDefaultLoggerFactory(),
}, false)
Expand All @@ -49,7 +49,7 @@ func TestSimpleReadWrite(t *testing.T) {
}
}()

client, err := testClient(ctx, util.FromConn(ca), ca.RemoteAddr(), &Config{
client, err := testClient(ctx, dtlsnet.PacketConnFromConn(ca), ca.RemoteAddr(), &Config{
LoggerFactory: logging.NewDefaultLoggerFactory(),
InsecureSkipVerify: true,
}, false)
Expand Down Expand Up @@ -79,7 +79,7 @@ func benchmarkConn(b *testing.B, n int64) {
certificate, err := selfsign.GenerateSelfSigned()
server := make(chan *Conn)
go func() {
s, sErr := testServer(ctx, util.FromConn(cb), cb.RemoteAddr(), &Config{
s, sErr := testServer(ctx, dtlsnet.PacketConnFromConn(cb), cb.RemoteAddr(), &Config{
Certificates: []tls.Certificate{certificate},
}, false)
if err != nil {
Expand All @@ -95,7 +95,7 @@ func benchmarkConn(b *testing.B, n int64) {
b.ReportAllocs()
b.SetBytes(int64(len(hw)))
go func() {
client, cErr := testClient(ctx, util.FromConn(ca), ca.RemoteAddr(), &Config{InsecureSkipVerify: true}, false)
client, cErr := testClient(ctx, dtlsnet.PacketConnFromConn(ca), ca.RemoteAddr(), &Config{InsecureSkipVerify: true}, false)
if cErr != nil {
b.Error(err)
}
Expand Down
6 changes: 3 additions & 3 deletions cipher_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"time"

"github.com/pion/dtls/v2/internal/ciphersuite"
"github.com/pion/dtls/v2/internal/util"
dtlsnet "github.com/pion/dtls/v2/pkg/net"
"github.com/pion/transport/v2/dpipe"
"github.com/pion/transport/v2/test"
)
Expand Down Expand Up @@ -71,14 +71,14 @@ func TestCustomCipherSuite(t *testing.T) {
c := make(chan result)

go func() {
client, err := testClient(ctx, util.FromConn(ca), ca.RemoteAddr(), &Config{
client, err := testClient(ctx, dtlsnet.PacketConnFromConn(ca), ca.RemoteAddr(), &Config{
CipherSuites: []CipherSuiteID{},
CustomCipherSuites: cipherFactory,
}, true)
c <- result{client, err}
}()

server, err := testServer(ctx, util.FromConn(cb), cb.RemoteAddr(), &Config{
server, err := testServer(ctx, dtlsnet.PacketConnFromConn(cb), cb.RemoteAddr(), &Config{
CipherSuites: []CipherSuiteID{},
CustomCipherSuites: cipherFactory,
}, true)
Expand Down
10 changes: 5 additions & 5 deletions conn_go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"testing"
"time"

"github.com/pion/dtls/v2/internal/util"
"github.com/pion/dtls/v2/pkg/crypto/selfsign"
dtlsnet "github.com/pion/dtls/v2/pkg/net"
"github.com/pion/transport/v2/dpipe"
"github.com/pion/transport/v2/test"
)
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestContextConfig(t *testing.T) {
f: func() (func() (net.Conn, error), func()) {
ca, _ := dpipe.Pipe()
return func() (net.Conn, error) {
return Client(util.FromConn(ca), ca.RemoteAddr(), config)
return Client(dtlsnet.PacketConnFromConn(ca), ca.RemoteAddr(), config)
}, func() {
_ = ca.Close()
}
Expand All @@ -98,7 +98,7 @@ func TestContextConfig(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 80*time.Millisecond)
ca, _ := dpipe.Pipe()
return func() (net.Conn, error) {
return ClientWithContext(ctx, util.FromConn(ca), ca.RemoteAddr(), config)
return ClientWithContext(ctx, dtlsnet.PacketConnFromConn(ca), ca.RemoteAddr(), config)
}, func() {
cancel()
_ = ca.Close()
Expand All @@ -110,7 +110,7 @@ func TestContextConfig(t *testing.T) {
f: func() (func() (net.Conn, error), func()) {
ca, _ := dpipe.Pipe()
return func() (net.Conn, error) {
return Server(util.FromConn(ca), ca.RemoteAddr(), config)
return Server(dtlsnet.PacketConnFromConn(ca), ca.RemoteAddr(), config)
}, func() {
_ = ca.Close()
}
Expand All @@ -122,7 +122,7 @@ func TestContextConfig(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 80*time.Millisecond)
ca, _ := dpipe.Pipe()
return func() (net.Conn, error) {
return ServerWithContext(ctx, util.FromConn(ca), ca.RemoteAddr(), config)
return ServerWithContext(ctx, dtlsnet.PacketConnFromConn(ca), ca.RemoteAddr(), config)
}, func() {
cancel()
_ = ca.Close()
Expand Down
Loading

0 comments on commit 703da0c

Please sign in to comment.