github.com/xmplusdev/xray-core@v1.8.10/app/policy/manager_test.go (about) 1 package policy_test 2 3 import ( 4 "context" 5 "testing" 6 "time" 7 8 . "github.com/xmplusdev/xray-core/app/policy" 9 "github.com/xmplusdev/xray-core/common" 10 "github.com/xmplusdev/xray-core/features/policy" 11 ) 12 13 func TestPolicy(t *testing.T) { 14 manager, err := New(context.Background(), &Config{ 15 Level: map[uint32]*Policy{ 16 0: { 17 Timeout: &Policy_Timeout{ 18 Handshake: &Second{ 19 Value: 2, 20 }, 21 }, 22 }, 23 }, 24 }) 25 common.Must(err) 26 27 pDefault := policy.SessionDefault() 28 29 { 30 p := manager.ForLevel(0) 31 if p.Timeouts.Handshake != 2*time.Second { 32 t.Error("expect 2 sec timeout, but got ", p.Timeouts.Handshake) 33 } 34 if p.Timeouts.ConnectionIdle != pDefault.Timeouts.ConnectionIdle { 35 t.Error("expect ", pDefault.Timeouts.ConnectionIdle, " sec timeout, but got ", p.Timeouts.ConnectionIdle) 36 } 37 } 38 39 { 40 p := manager.ForLevel(1) 41 if p.Timeouts.Handshake != pDefault.Timeouts.Handshake { 42 t.Error("expect ", pDefault.Timeouts.Handshake, " sec timeout, but got ", p.Timeouts.Handshake) 43 } 44 } 45 }