function to compare byte array

This commit is contained in:
Darien Raymond
2018-07-12 23:38:10 +02:00
parent eb2bd40157
commit 29ad2cbbdb
12 changed files with 132 additions and 70 deletions
+2 -3
View File
@@ -56,7 +56,7 @@ func NewID(uuid uuid.UUID) *ID {
return id
}
func nextId(u *uuid.UUID) uuid.UUID {
func nextID(u *uuid.UUID) uuid.UUID {
md5hash := md5.New()
common.Must2(md5hash.Write(u.Bytes()))
common.Must2(md5hash.Write([]byte("16167dc8-16b6-4e6d-b8bb-65dd68113a81")))
@@ -74,8 +74,7 @@ func NewAlterIDs(primary *ID, alterIDCount uint16) []*ID {
alterIDs := make([]*ID, alterIDCount)
prevID := primary.UUID()
for idx := range alterIDs {
newid := nextId(&prevID)
// TODO: check duplicates
newid := nextID(&prevID)
alterIDs[idx] = NewID(newid)
prevID = newid
}
+2 -2
View File
@@ -3,7 +3,7 @@ package protocol_test
import (
"testing"
"v2ray.com/core/common/predicate"
"v2ray.com/core/common/compare"
. "v2ray.com/core/common/protocol"
"v2ray.com/core/common/uuid"
. "v2ray.com/ext/assert"
@@ -13,7 +13,7 @@ func TestCmdKey(t *testing.T) {
assert := With(t)
id := NewID(uuid.New())
assert(predicate.BytesAll(id.CmdKey(), 0), IsFalse)
assert(compare.BytesAll(id.CmdKey(), 0), IsFalse)
}
func TestIdEquals(t *testing.T) {