Commit eaad3924 authored by Luke Champine's avatar Luke Champine

bytes.Compare(a, b) != 0 -> !bytes.Equal(a, b)

parent dee42389
......@@ -26,7 +26,7 @@ func TestTwofishEncryption(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if bytes.Compare(plaintext, decryptedPlaintext) != 0 {
if !bytes.Equal(plaintext, decryptedPlaintext) {
t.Fatal("Encrypted and decrypted zero plaintext do not match")
}
......@@ -44,7 +44,7 @@ func TestTwofishEncryption(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if bytes.Compare(plaintext, decryptedPlaintext) != 0 {
if !bytes.Equal(plaintext, decryptedPlaintext) {
t.Fatal("Encrypted and decrypted zero plaintext do not match")
}
......@@ -103,7 +103,7 @@ func TestReaderWriter(t *testing.T) {
var decrypted = make([]byte, plaintextSize)
key.NewReader(buf).Read(decrypted)
if bytes.Compare(plaintext, decrypted) != 0 {
if !bytes.Equal(plaintext, decrypted) {
t.Error("couldn't decrypt encrypted stream")
}
}
......
......@@ -84,7 +84,7 @@ func TestEncode(t *testing.T) {
// use Marshal for convenience
for i := range testStructs {
b := Marshal(testStructs[i])
if bytes.Compare(b, testEncodings[i]) != 0 {
if !bytes.Equal(b, testEncodings[i]) {
t.Errorf("bad encoding of testStructs[%d]: \nexp:\t%v\ngot:\t%v", i, testEncodings[i], b)
}
}
......@@ -207,7 +207,7 @@ func TestMarshalAll(t *testing.T) {
}
expected := MarshalAll(testStructs...)
if bytes.Compare(b, expected) != 0 {
if !bytes.Equal(b, expected) {
t.Errorf("expected %v, got %v", expected, b)
}
}
......
......@@ -106,7 +106,7 @@ func TestWritePrefix(t *testing.T) {
expected := append(EncUint64(3), "foo"...)
if err != nil {
t.Error(err)
} else if bytes.Compare(b.Bytes(), expected) != 0 {
} else if !bytes.Equal(b.Bytes(), expected) {
t.Errorf("WritePrefix wrote wrong data: expected %v, got %v", b.Bytes(), expected)
}
......@@ -126,7 +126,7 @@ func TestWriteObject(t *testing.T) {
expected := append(EncUint64(11), append(EncUint64(3), "foo"...)...)
if err != nil {
t.Error(err)
} else if bytes.Compare(b.Bytes(), expected) != 0 {
} else if !bytes.Equal(b.Bytes(), expected) {
t.Errorf("WritePrefix wrote wrong data: expected %v, got %v", b.Bytes(), expected)
}
......@@ -150,7 +150,7 @@ func TestReadWritePrefix(t *testing.T) {
rdata, err := ReadPrefix(b, 100)
if err != nil {
t.Error(err)
} else if bytes.Compare(rdata, data) != 0 {
} else if !bytes.Equal(rdata, data) {
t.Errorf("read/write mismatch: wrote %s, read %s", data, rdata)
}
......
......@@ -71,7 +71,7 @@ func (e *Explorer) GetHashInfo(hash []byte) (interface{}, error) {
uhChecksum := crypto.HashObject(id)
givenChecksum := hash[crypto.HashSize : crypto.HashSize+types.UnlockHashChecksumSize]
if bytes.Compare(givenChecksum, uhChecksum[:types.UnlockHashChecksumSize]) != 0 {
if !bytes.Equal(givenChecksum, uhChecksum[:types.UnlockHashChecksumSize]) {
return nil, errors.New("address does not have a valid checksum")
}
......
......@@ -31,7 +31,7 @@ func TestRSEncode(t *testing.T) {
}
buf.Truncate(777)
if bytes.Compare(data, buf.Bytes()) != 0 {
if !bytes.Equal(data, buf.Bytes()) {
t.Fatal("recovered data does not match original")
}
}
......
......@@ -142,7 +142,7 @@ func TestCurrencyMarshalJSON(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if bytes.Compare(bMar30, cMar30) != 0 {
if !bytes.Equal(bMar30, cMar30) {
t.Error("Currency does not match the marshalling of its math/big equivalent")
}
......
......@@ -454,7 +454,7 @@ func (uh *UnlockHash) LoadString(strUH string) error {
// Verify the checksum - leave uh as-is unless the checksum is valid.
expectedChecksum := crypto.HashBytes(byteUnlockHash)
if bytes.Compare(expectedChecksum[:UnlockHashChecksumSize], checksum) != 0 {
if !bytes.Equal(expectedChecksum[:UnlockHashChecksumSize], checksum) {
return ErrInvalidUnlockHashChecksum
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment