github.com/xraypb/Xray-core@v1.8.1/common/protocol/time_test.go (about) 1 package protocol_test 2 3 import ( 4 "testing" 5 "time" 6 7 . "github.com/xraypb/Xray-core/common/protocol" 8 ) 9 10 func TestGenerateRandomInt64InRange(t *testing.T) { 11 base := time.Now().Unix() 12 delta := 100 13 generator := NewTimestampGenerator(Timestamp(base), delta) 14 15 for i := 0; i < 100; i++ { 16 val := int64(generator()) 17 if val > base+int64(delta) || val < base-int64(delta) { 18 t.Error(val, " not between ", base-int64(delta), " and ", base+int64(delta)) 19 } 20 } 21 }