mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-30 05:56:54 -05:00
format code
This commit is contained in:
parent
5559c1ca60
commit
f1292f6035
@ -16,7 +16,7 @@ func TestAuthenticationRequestRead(t *testing.T) {
|
||||
0x02, // methods
|
||||
}
|
||||
request, err := ReadAuthentication(bytes.NewReader(rawRequest))
|
||||
assert.Error(err).IsNil()
|
||||
assert.Error(err).IsNil()
|
||||
assert.Byte(request.version).Named("Version").Equals(0x05)
|
||||
assert.Byte(request.nMethods).Named("#Methods").Equals(0x01)
|
||||
assert.Byte(request.authMethods[0]).Named("Auth Method").Equals(0x02)
|
||||
@ -46,7 +46,7 @@ func TestRequestRead(t *testing.T) {
|
||||
0x00, 0x35, // port 53
|
||||
}
|
||||
request, err := ReadRequest(bytes.NewReader(rawRequest))
|
||||
assert.Error(err).IsNil()
|
||||
assert.Error(err).IsNil()
|
||||
assert.Byte(request.Version).Named("Version").Equals(0x05)
|
||||
assert.Byte(request.Command).Named("Command").Equals(0x01)
|
||||
assert.Byte(request.AddrType).Named("Address Type").Equals(0x01)
|
||||
|
@ -7,21 +7,21 @@ import (
|
||||
"crypto/rand"
|
||||
mrand "math/rand"
|
||||
"testing"
|
||||
|
||||
"github.com/v2ray/v2ray-core/testing/unit"
|
||||
|
||||
"github.com/v2ray/v2ray-core/testing/unit"
|
||||
)
|
||||
|
||||
func randomBytes(p []byte, t *testing.T) {
|
||||
assert := unit.Assert(t)
|
||||
|
||||
assert := unit.Assert(t)
|
||||
|
||||
nBytes, err := rand.Read(p)
|
||||
assert.Error(err).IsNil()
|
||||
assert.Int(nBytes).Named("# bytes of random buffer").Equals(len(p))
|
||||
assert.Error(err).IsNil()
|
||||
assert.Int(nBytes).Named("# bytes of random buffer").Equals(len(p))
|
||||
}
|
||||
|
||||
func TestNormalReading(t *testing.T) {
|
||||
assert := unit.Assert(t)
|
||||
|
||||
assert := unit.Assert(t)
|
||||
|
||||
testSize := 256
|
||||
plaintext := make([]byte, testSize)
|
||||
randomBytes(plaintext, t)
|
||||
@ -33,8 +33,8 @@ func TestNormalReading(t *testing.T) {
|
||||
randomBytes(iv, t)
|
||||
|
||||
aesBlock, err := aes.NewCipher(key)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
aesMode := cipher.NewCBCEncrypter(aesBlock, iv)
|
||||
|
||||
ciphertext := make([]byte, testSize)
|
||||
@ -55,8 +55,8 @@ func TestNormalReading(t *testing.T) {
|
||||
}
|
||||
bytesRead, err := reader.Read(readtext[readSize : readSize+nBytes])
|
||||
assert.Error(err).IsNil()
|
||||
assert.Int(bytesRead).Equals(nBytes)
|
||||
assert.Int(bytesRead).Equals(nBytes)
|
||||
readSize += nBytes
|
||||
}
|
||||
assert.Bytes(readtext).Named("Plaintext").Equals(plaintext)
|
||||
assert.Bytes(readtext).Named("Plaintext").Equals(plaintext)
|
||||
}
|
||||
|
@ -33,9 +33,9 @@ func (a *Assertion) Bytes(value []byte) *BytesSubject {
|
||||
}
|
||||
|
||||
func (a *Assertion) String(value string) *StringSubject {
|
||||
return NewStringSubject(NewSubject(a), value)
|
||||
return NewStringSubject(NewSubject(a), value)
|
||||
}
|
||||
|
||||
func (a *Assertion) Error(value error) *ErrorSubject {
|
||||
return NewErrorSubject(NewSubject(a), value)
|
||||
return NewErrorSubject(NewSubject(a), value)
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ func (subject *ErrorSubject) Equals(expectation error) {
|
||||
}
|
||||
|
||||
func (subject *ErrorSubject) IsNil() {
|
||||
if subject.value != nil {
|
||||
subject.FailWithMessage("Not true that " + subject.DisplayString() + " is nil.")
|
||||
}
|
||||
}
|
||||
if subject.value != nil {
|
||||
subject.FailWithMessage("Not true that " + subject.DisplayString() + " is nil.")
|
||||
}
|
||||
}
|
||||
|
10
vid_test.go
10
vid_test.go
@ -2,16 +2,16 @@ package core
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/v2ray/v2ray-core/testing/unit"
|
||||
|
||||
"github.com/v2ray/v2ray-core/testing/unit"
|
||||
)
|
||||
|
||||
func TestUUIDToVID(t *testing.T) {
|
||||
assert := unit.Assert(t)
|
||||
|
||||
assert := unit.Assert(t)
|
||||
|
||||
uuid := "2418d087-648d-4990-86e8-19dca1d006d3"
|
||||
expectedBytes := []byte{0x24, 0x18, 0xd0, 0x87, 0x64, 0x8d, 0x49, 0x90, 0x86, 0xe8, 0x19, 0xdc, 0xa1, 0xd0, 0x06, 0xd3}
|
||||
|
||||
actualBytes, _ := UUIDToVID(uuid)
|
||||
assert.Bytes(actualBytes[:]).Named("UUID").Equals(expectedBytes)
|
||||
assert.Bytes(actualBytes[:]).Named("UUID").Equals(expectedBytes)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user