mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
another goconvey test for RequestOffer, fix data race in the Broker test
This commit is contained in:
parent
2ae6559001
commit
661286894a
1 changed files with 25 additions and 10 deletions
|
@ -22,20 +22,35 @@ func TestBroker(t *testing.T) {
|
||||||
So(len(ctx.idToSnowflake), ShouldEqual, 1)
|
So(len(ctx.idToSnowflake), ShouldEqual, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
/*
|
|
||||||
Convey("Broker goroutine matches clients with proxies", func() {
|
Convey("Broker goroutine matches clients with proxies", func() {
|
||||||
ctx2 := NewBrokerContext()
|
|
||||||
p := new(ProxyPoll)
|
p := new(ProxyPoll)
|
||||||
p.id = "test"
|
p.id = "test"
|
||||||
go func() {
|
p.offerChannel = make(chan []byte)
|
||||||
ctx2.proxyPolls <- p
|
go func(ctx *BrokerContext) {
|
||||||
close(ctx2.proxyPolls)
|
ctx.proxyPolls <- p
|
||||||
}()
|
close(ctx.proxyPolls)
|
||||||
ctx2.Broker()
|
}(ctx)
|
||||||
So(ctx2.snowflakes.Len(), ShouldEqual, 1)
|
ctx.Broker()
|
||||||
So(ctx2.idToSnowflake["test"], ShouldNotBeNil)
|
So(ctx.snowflakes.Len(), ShouldEqual, 1)
|
||||||
|
snowflake := heap.Pop(ctx.snowflakes).(*Snowflake)
|
||||||
|
snowflake.offerChannel <- []byte("test offer")
|
||||||
|
offer := <-p.offerChannel
|
||||||
|
So(ctx.idToSnowflake["test"], ShouldNotBeNil)
|
||||||
|
So(offer, ShouldResemble, []byte("test offer"))
|
||||||
|
So(ctx.snowflakes.Len(), ShouldEqual, 0)
|
||||||
|
})
|
||||||
|
|
||||||
|
Convey("Request an offer from the Snowflake Heap", func() {
|
||||||
|
done := make(chan []byte)
|
||||||
|
go func() {
|
||||||
|
offer := ctx.RequestOffer("test")
|
||||||
|
done <- offer
|
||||||
|
}()
|
||||||
|
request := <-ctx.proxyPolls
|
||||||
|
request.offerChannel <- []byte("test offer")
|
||||||
|
offer := <-done
|
||||||
|
So(offer, ShouldResemble, []byte("test offer"))
|
||||||
})
|
})
|
||||||
*/
|
|
||||||
|
|
||||||
Convey("Responds to client offers...", func() {
|
Convey("Responds to client offers...", func() {
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue