Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions common/uint160_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package common
import (
"encoding/hex"
"encoding/json"
"slices"
"testing"
)

Expand All @@ -29,7 +30,7 @@ func TestMarshalJSON(t *testing.T) {
t.Fatalf("Unexpected error: %v", err)
}

if !bytesEqual(bytes, expected) {
if !slices.Equal(bytes, expected) {
t.Fatalf("Expected %v, got %v", expected, bytes)
}

Expand All @@ -38,7 +39,7 @@ func TestMarshalJSON(t *testing.T) {
t.Fatalf("Unexpected error: %v", err)
}

if !bytesEqual(bytes, expected) {
if !slices.Equal(bytes, expected) {
t.Fatalf("Expected %v, got %v", expected, bytes)
}

Expand All @@ -61,22 +62,10 @@ func TestUnmarshalJSON(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if !bytesEqual(f.ToArray(), expected) {
if !slices.Equal(f.ToArray(), expected) {
t.Fatalf("Expected %v, got %v", expected, f.ToArray())
}

// TODO: If possible, create a scenario where ToScriptHash returns an error
// and verify that UnmarshalJSON also returns this error.
}

func bytesEqual(a, b []byte) bool {
if len(a) != len(b) {
return false
}
for i, v := range a {
if v != b[i] {
return false
}
}
return true
}