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

46 lines
1010 B
Go
Raw Normal View History

2018-02-17 17:37:09 -05:00
package policy_test
import (
"context"
"testing"
"time"
. "github.com/v2fly/v2ray-core/v5/app/policy"
"github.com/v2fly/v2ray-core/v5/common"
"github.com/v2fly/v2ray-core/v5/features/policy"
2018-02-17 17:37:09 -05:00
)
func TestPolicy(t *testing.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,
},
},
},
},
})
2019-01-06 17:30:38 -05:00
common.Must(err)
2018-02-17 17:37:09 -05:00
2018-10-11 16:34:31 -04:00
pDefault := policy.SessionDefault()
2018-02-17 17:37:09 -05:00
2019-01-06 17:30:38 -05: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 17:37:09 -05:00
2019-01-06 17:30:38 -05: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 17:37:09 -05:00
}