1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 18:17:52 -05:00
v2fly/app/policy/manager_test.go

38 lines
713 B
Go
Raw Normal View History

2018-02-17 17:37:09 -05:00
package policy_test
import (
"context"
"testing"
"time"
. "v2ray.com/core/app/policy"
2018-10-11 16:34:31 -04:00
"v2ray.com/core/features/policy"
2018-02-17 17:37:09 -05:00
. "v2ray.com/ext/assert"
)
func TestPolicy(t *testing.T) {
assert := With(t)
manager, err := New(context.Background(), &Config{
Level: map[uint32]*Policy{
2018-02-22 04:34:14 -05:00
0: {
2018-02-17 17:37:09 -05:00
Timeout: &Policy_Timeout{
Handshake: &Second{
Value: 2,
},
},
},
},
})
assert(err, IsNil)
2018-10-11 16:34:31 -04:00
pDefault := policy.SessionDefault()
2018-02-17 17:37:09 -05:00
p0 := manager.ForLevel(0)
assert(p0.Timeouts.Handshake, Equals, 2*time.Second)
assert(p0.Timeouts.ConnectionIdle, Equals, pDefault.Timeouts.ConnectionIdle)
p1 := manager.ForLevel(1)
assert(p1.Timeouts.Handshake, Equals, pDefault.Timeouts.Handshake)
}