mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Use gorilla websocket in proxy-go too
Trac: 32465
This commit is contained in:
parent
7557e96a8d
commit
30b5ef8a9e
5 changed files with 128 additions and 134 deletions
30
common/websocketconn/websocketconn_test.go
Normal file
30
common/websocketconn/websocketconn_test.go
Normal file
|
@ -0,0 +1,30 @@
|
|||
package websocketconn
|
||||
|
||||
import (
|
||||
"net"
|
||||
"testing"
|
||||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
|
||||
func TestWebsocketConn(t *testing.T) {
|
||||
Convey("CopyLoop", t, func() {
|
||||
c1, s1 := net.Pipe()
|
||||
c2, s2 := net.Pipe()
|
||||
go CopyLoop(s1, s2)
|
||||
go func() {
|
||||
bytes := []byte("Hello!")
|
||||
c1.Write(bytes)
|
||||
}()
|
||||
bytes := make([]byte, 6)
|
||||
n, err := c2.Read(bytes)
|
||||
So(n, ShouldEqual, 6)
|
||||
So(err, ShouldEqual, nil)
|
||||
So(bytes, ShouldResemble, []byte("Hello!"))
|
||||
s1.Close()
|
||||
|
||||
// Check that copy loop has closed other connection
|
||||
_, err = s2.Write(bytes)
|
||||
So(err, ShouldNotBeNil)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue