mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 09:18:34 +00:00
Fix some tests and format code (#830)
* Increase some tls test timeout * Fix TestUserValidator * Change all tests to VMessAEAD Old VMess MD5 tests will be rejected and fail in 2022 * Chore: auto format code
This commit is contained in:
parent
d5a7901601
commit
e93da4bd02
77 changed files with 137 additions and 234 deletions
|
@ -2,7 +2,6 @@ package vmess_test
|
|||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/xtls/xray-core/common"
|
||||
"github.com/xtls/xray-core/common/protocol"
|
||||
|
@ -26,15 +25,14 @@ func TestUserValidator(t *testing.T) {
|
|||
user := &protocol.MemoryUser{
|
||||
Email: "test",
|
||||
Account: toAccount(&Account{
|
||||
Id: id.String(),
|
||||
AlterId: 8,
|
||||
Id: id.String(),
|
||||
}),
|
||||
}
|
||||
common.Must(v.Add(user))
|
||||
|
||||
{
|
||||
testSmallLag := func(lag time.Duration) {
|
||||
ts := protocol.Timestamp(time.Now().Add(time.Second * lag).Unix())
|
||||
testSmallLag := func(lag int64) {
|
||||
ts := int64(v.GetBaseTime()) + lag + 240
|
||||
idHash := hasher(id.Bytes())
|
||||
common.Must2(serial.WriteUint64(idHash, uint64(ts)))
|
||||
userHash := idHash.Sum(nil)
|
||||
|
@ -46,7 +44,7 @@ func TestUserValidator(t *testing.T) {
|
|||
if euser.Email != user.Email {
|
||||
t.Error("unexpected user email: ", euser.Email, " want ", user.Email)
|
||||
}
|
||||
if ets != ts {
|
||||
if int64(ets) != ts {
|
||||
t.Error("unexpected timestamp: ", ets, " want ", ts)
|
||||
}
|
||||
}
|
||||
|
@ -61,8 +59,8 @@ func TestUserValidator(t *testing.T) {
|
|||
}
|
||||
|
||||
{
|
||||
testBigLag := func(lag time.Duration) {
|
||||
ts := protocol.Timestamp(time.Now().Add(time.Second * lag).Unix())
|
||||
testBigLag := func(lag int64) {
|
||||
ts := int64(v.GetBaseTime()) + lag + 240
|
||||
idHash := hasher(id.Bytes())
|
||||
common.Must2(serial.WriteUint64(idHash, uint64(ts)))
|
||||
userHash := idHash.Sum(nil)
|
||||
|
@ -99,8 +97,7 @@ func BenchmarkUserValidator(b *testing.B) {
|
|||
v.Add(&protocol.MemoryUser{
|
||||
Email: "test",
|
||||
Account: toAccount(&Account{
|
||||
Id: id.String(),
|
||||
AlterId: 16,
|
||||
Id: id.String(),
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue