address: improve testing, make it 100% covered

This commit is contained in:
Roman Khimov 2019-12-25 15:55:39 +03:00
parent c5ceb9128a
commit b7702f3a2e

View file

@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
) )
func TestUint160DecodeEncodeAddress(t *testing.T) { func TestUint160DecodeEncodeAddress(t *testing.T) {
@ -32,3 +33,18 @@ func TestUint160DecodeKnownAddress(t *testing.T) {
assert.Equal(t, "b28427088a3729b2536d10122960394e8be6721f", val.StringLE()) assert.Equal(t, "b28427088a3729b2536d10122960394e8be6721f", val.StringLE())
assert.Equal(t, "1f72e68b4e39602912106d53b229378a082784b2", val.String()) assert.Equal(t, "1f72e68b4e39602912106d53b229378a082784b2", val.String())
} }
func TestUint160DecodeBadBase58(t *testing.T) {
address := "AJeAEsmeD6t279Dx4n2HWdUvUmmXQ4iJv@"
_, err := DecodeUint160(address)
require.Error(t, err)
}
func TestUint160DecodeBadPrefix(t *testing.T) {
// The same AJeAEsmeD6t279Dx4n2HWdUvUmmXQ4iJvP key encoded with 0x18 prefix.
address := "AhymDz4vvHLtvaN36CMbzkki7H2U8ENb8F"
_, err := DecodeUint160(address)
require.Error(t, err)
}