mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Turn the proxy code into a library
Allow other go programs to easily import the snowflake proxy library and start/stop a snowflake proxy.
This commit is contained in:
parent
54ab79384f
commit
50e4f4fd61
7 changed files with 184 additions and 99 deletions
28
proxy/lib/tokens_test.go
Normal file
28
proxy/lib/tokens_test.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package snowflake
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
|
||||
func TestTokens(t *testing.T) {
|
||||
Convey("Tokens", t, func() {
|
||||
tokens := newTokens(2)
|
||||
So(tokens.count(), ShouldEqual, 0)
|
||||
tokens.get()
|
||||
So(tokens.count(), ShouldEqual, 1)
|
||||
tokens.ret()
|
||||
So(tokens.count(), ShouldEqual, 0)
|
||||
})
|
||||
Convey("Tokens capacity 0", t, func() {
|
||||
tokens := newTokens(0)
|
||||
So(tokens.count(), ShouldEqual, 0)
|
||||
for i := 0; i < 20; i++ {
|
||||
tokens.get()
|
||||
}
|
||||
So(tokens.count(), ShouldEqual, 20)
|
||||
tokens.ret()
|
||||
So(tokens.count(), ShouldEqual, 19)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue