1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-18 02:16:10 -05:00
v2fly/common/protocol/server_spec_test.go

32 lines
698 B
Go
Raw Normal View History

2016-07-25 10:48:09 -04:00
package protocol_test
import (
"testing"
2016-07-25 15:31:16 -04:00
"time"
2016-07-25 10:48:09 -04:00
2016-08-20 14:55:45 -04:00
. "v2ray.com/core/common/protocol"
"v2ray.com/core/testing/assert"
2016-07-25 10:48:09 -04:00
)
2016-07-25 15:31:16 -04:00
func TestAlwaysValidStrategy(t *testing.T) {
assert := assert.On(t)
strategy := AlwaysValid()
assert.Bool(strategy.IsValid()).IsTrue()
strategy.Invalidate()
assert.Bool(strategy.IsValid()).IsTrue()
}
func TestTimeoutValidStrategy(t *testing.T) {
assert := assert.On(t)
strategy := BeforeTime(time.Now().Add(2 * time.Second))
assert.Bool(strategy.IsValid()).IsTrue()
time.Sleep(3 * time.Second)
assert.Bool(strategy.IsValid()).IsFalse()
strategy = BeforeTime(time.Now().Add(2 * time.Second))
strategy.Invalidate()
assert.Bool(strategy.IsValid()).IsFalse()
}