mirror of https://github.com/cbeuw/Cloak
Fix tests
This commit is contained in:
parent
3649283a49
commit
e2b21dae9f
|
|
@ -9,9 +9,17 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSwitchboard_Send(t *testing.T) {
|
func TestSwitchboard_Send(t *testing.T) {
|
||||||
|
getHole := func() net.Conn {
|
||||||
|
l, _ := net.Listen("tcp", "127.0.0.1:0")
|
||||||
|
go func() {
|
||||||
|
net.Dial("tcp", l.Addr().String())
|
||||||
|
}()
|
||||||
|
hole, _ := l.Accept()
|
||||||
|
return hole
|
||||||
|
}
|
||||||
doTest := func(seshConfig *SessionConfig) {
|
doTest := func(seshConfig *SessionConfig) {
|
||||||
sesh := MakeSession(0, seshConfig)
|
sesh := MakeSession(0, seshConfig)
|
||||||
hole0 := newBlackHole()
|
hole0 := getHole()
|
||||||
sesh.sb.addConn(hole0)
|
sesh.sb.addConn(hole0)
|
||||||
connId, err := sesh.sb.assignRandomConn()
|
connId, err := sesh.sb.assignRandomConn()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -26,7 +34,7 @@ func TestSwitchboard_Send(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
hole1 := newBlackHole()
|
hole1 := getHole()
|
||||||
sesh.sb.addConn(hole1)
|
sesh.sb.addConn(hole1)
|
||||||
connId, err = sesh.sb.assignRandomConn()
|
connId, err = sesh.sb.assignRandomConn()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -39,8 +47,6 @@ func TestSwitchboard_Send(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
hole0.Close()
|
|
||||||
|
|
||||||
connId, err = sesh.sb.assignRandomConn()
|
connId, err = sesh.sb.assignRandomConn()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("failed to get a random conn", err)
|
t.Error("failed to get a random conn", err)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue