1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-28 18:25:23 +00:00
v2fly/app/policy/manager_test.go

46 lines
1010 B
Go
Raw Normal View History

2018-02-17 22:37:09 +00:00
package policy_test
import (
"context"
"testing"
"time"
2021-02-16 20:31:50 +00:00
. "github.com/v2fly/v2ray-core/v4/app/policy"
"github.com/v2fly/v2ray-core/v4/common"
"github.com/v2fly/v2ray-core/v4/features/policy"
2018-02-17 22:37:09 +00:00
)
func TestPolicy(t *testing.T) {
manager, err := New(context.Background(), &Config{
Level: map[uint32]*Policy{
2018-02-22 09:34:14 +00:00
0: {
2018-02-17 22:37:09 +00:00
Timeout: &Policy_Timeout{
Handshake: &Second{
Value: 2,
},
},
},
},
})
2019-01-06 22:30:38 +00:00
common.Must(err)
2018-02-17 22:37:09 +00:00
2018-10-11 20:34:31 +00:00
pDefault := policy.SessionDefault()
2018-02-17 22:37:09 +00:00
2019-01-06 22:30:38 +00:00
{
p := manager.ForLevel(0)
if p.Timeouts.Handshake != 2*time.Second {
t.Error("expect 2 sec timeout, but got ", p.Timeouts.Handshake)
}
if p.Timeouts.ConnectionIdle != pDefault.Timeouts.ConnectionIdle {
t.Error("expect ", pDefault.Timeouts.ConnectionIdle, " sec timeout, but got ", p.Timeouts.ConnectionIdle)
}
}
2018-02-17 22:37:09 +00:00
2019-01-06 22:30:38 +00:00
{
p := manager.ForLevel(1)
if p.Timeouts.Handshake != pDefault.Timeouts.Handshake {
t.Error("expect ", pDefault.Timeouts.Handshake, " sec timeout, but got ", p.Timeouts.Handshake)
}
}
2018-02-17 22:37:09 +00:00
}