diff --git a/common/uint160.go b/common/uint160.go index b7396308..fe816c52 100644 --- a/common/uint160.go +++ b/common/uint160.go @@ -89,7 +89,7 @@ func IsValidHexAddr(s []byte) bool { return false } -func (f *Uint160) MarshalJSON() ([]byte, error) { +func (f Uint160) MarshalJSON() ([]byte, error) { str, err := f.ToAddress() return []byte("\"" + str + "\""), err } diff --git a/common/uint160_test.go b/common/uint160_test.go index cb54012d..ed8f0d31 100644 --- a/common/uint160_test.go +++ b/common/uint160_test.go @@ -2,6 +2,7 @@ package common import ( "encoding/hex" + "encoding/json" "testing" ) @@ -23,7 +24,16 @@ func TestMarshalJSON(t *testing.T) { // Expected value after Marshalling expected := []byte(NKNADDRESS) - bytes, err := f.MarshalJSON() + bytes, err := json.Marshal(f) + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } + + if !bytesEqual(bytes, expected) { + t.Fatalf("Expected %v, got %v", expected, bytes) + } + + bytes, err = json.Marshal(*f) if err != nil { t.Fatalf("Unexpected error: %v", err) }