mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Add unit tests to check for webrtc peer data races
This commit is contained in:
parent
bb7ff6180b
commit
95cbe36565
1 changed files with 31 additions and 0 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"net"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.torproject.org/pluggable-transports/snowflake.git/common/util"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
|
@ -154,6 +155,25 @@ func TestSnowflakeClient(t *testing.T) {
|
|||
So(r, ShouldEqual, wc4)
|
||||
})
|
||||
|
||||
Convey("Terminate Connect() loop", func() {
|
||||
p, _ := NewPeers(FakeDialer{max: 4})
|
||||
go func() {
|
||||
for {
|
||||
p.Collect()
|
||||
select {
|
||||
case <-p.Melted():
|
||||
return
|
||||
default:
|
||||
}
|
||||
}
|
||||
}()
|
||||
<-time.After(10 * time.Second)
|
||||
|
||||
p.End()
|
||||
<-p.Melted()
|
||||
So(p.Count(), ShouldEqual, 0)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Convey("Dialers", t, func() {
|
||||
|
@ -245,6 +265,17 @@ func TestSnowflakeClient(t *testing.T) {
|
|||
|
||||
}
|
||||
|
||||
func TestWebRTCPeer(t *testing.T) {
|
||||
Convey("WebRTCPeer", t, func(c C) {
|
||||
p := &WebRTCPeer{closed: make(chan struct{})}
|
||||
Convey("checks for staleness", func() {
|
||||
go p.checkForStaleness()
|
||||
<-time.After(2 * SnowflakeTimeout)
|
||||
So(p.Closed(), ShouldEqual, true)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func TestICEServerParser(t *testing.T) {
|
||||
Convey("Test parsing of ICE servers", t, func() {
|
||||
for _, test := range []struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue