Skip to content
This repository has been archived by the owner on Dec 25, 2024. It is now read-only.

Commit

Permalink
Add test based on nettest.TestConn.
Browse files Browse the repository at this point in the history
  • Loading branch information
NullHypothesis committed Mar 7, 2024
1 parent e1b23ad commit 3553f86
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"net"
"sync"
"testing"

"golang.org/x/net/nettest"
)

func assertEq(t *testing.T, is, should interface{}) {
Expand All @@ -26,6 +28,22 @@ func (b *buffer) Close() error {
return nil
}

func TestNettest(t *testing.T) {
mkPipe := func() (c1, c2 net.Conn, stop func(), err error) {
var (
in, out = net.Pipe()
fwd1, fwd2 = net.Pipe()
wg = sync.WaitGroup{}
ch = make(chan error)
)
wg.Add(2)
go TunToVsock(in, fwd1, ch, &wg)
go VsockToTun(fwd2, out, ch, &wg)
return in, out, func() {}, nil
}
nettest.TestConn(t, nettest.MakePipe(mkPipe))
}

func TestAToB(t *testing.T) {
var (
err error
Expand Down

0 comments on commit 3553f86

Please sign in to comment.