From d018dc4e569a29cc64e601c29c750e5eee89c1b1 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 25 Nov 2019 11:43:13 +0300 Subject: [PATCH] util: add missing tests for Uint160 --- pkg/util/uint160_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/util/uint160_test.go b/pkg/util/uint160_test.go index f2a37a74d..f8e37d297 100644 --- a/pkg/util/uint160_test.go +++ b/pkg/util/uint160_test.go @@ -25,6 +25,8 @@ func TestUint160UnmarshalJSON(t *testing.T) { // UnmarshalJSON decodes hex-strings prefixed by 0x assert.NoError(t, u2.UnmarshalJSON(s)) assert.True(t, expected.Equals(u1)) + + assert.Error(t, u2.UnmarshalJSON([]byte(`123`))) } func TestUInt160DecodeString(t *testing.T) { @@ -32,6 +34,13 @@ func TestUInt160DecodeString(t *testing.T) { val, err := Uint160DecodeString(hexStr) assert.NoError(t, err) assert.Equal(t, hexStr, val.String()) + + _, err = Uint160DecodeString(hexStr[1:]) + assert.Error(t, err) + + hexStr = "zz3b96ae1bcc5a585e075e3b81920210dec16302" + _, err = Uint160DecodeString(hexStr) + assert.Error(t, err) } func TestUint160DecodeBytes(t *testing.T) { @@ -42,6 +51,9 @@ func TestUint160DecodeBytes(t *testing.T) { val, err := Uint160DecodeBytes(b) assert.NoError(t, err) assert.Equal(t, hexStr, val.String()) + + _, err = Uint160DecodeBytes(b[1:]) + assert.Error(t, err) } func TestUInt160Equals(t *testing.T) {