mirror of https://github.com/v2ray/v2ray-core
format code
parent
69bcce0b0d
commit
9371b3d080
|
@ -26,7 +26,7 @@ func NewDecryptionReader(reader io.Reader, key []byte) (*DecryptionReader, error
|
||||||
}
|
}
|
||||||
decryptionReader.cipher = cipher
|
decryptionReader.cipher = cipher
|
||||||
decryptionReader.reader = reader
|
decryptionReader.reader = reader
|
||||||
decryptionReader.buffer = bytes.NewBuffer(make([]byte, 0, 2 * blockSize))
|
decryptionReader.buffer = bytes.NewBuffer(make([]byte, 0, 2*blockSize))
|
||||||
return decryptionReader, nil
|
return decryptionReader, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,10 +49,10 @@ func TestNormalReading(t *testing.T) {
|
||||||
readSize := 0
|
readSize := 0
|
||||||
for readSize < testSize {
|
for readSize < testSize {
|
||||||
nBytes := mrand.Intn(16) + 1
|
nBytes := mrand.Intn(16) + 1
|
||||||
if nBytes > testSize - readSize {
|
if nBytes > testSize-readSize {
|
||||||
nBytes = testSize - readSize
|
nBytes = testSize - readSize
|
||||||
}
|
}
|
||||||
bytesRead, err := reader.Read(readtext[readSize:readSize + nBytes])
|
bytesRead, err := reader.Read(readtext[readSize : readSize+nBytes])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ func TestNormalReading(t *testing.T) {
|
||||||
}
|
}
|
||||||
readSize += nBytes
|
readSize += nBytes
|
||||||
}
|
}
|
||||||
if ! bytes.Equal(readtext, plaintext) {
|
if !bytes.Equal(readtext, plaintext) {
|
||||||
t.Errorf("Expected plaintext %v, but got %v", plaintext, readtext)
|
t.Errorf("Expected plaintext %v, but got %v", plaintext, readtext)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue