neoneo-go/pkg/crypto/address_test.go
Roman Khimov 2275b9e4ad _pkg.dev: drop address pkg, move test into crypto
address wrappers don't seem to fit well into master's code, so just drop 'em,
but pick the testing function with good known input/output pair.
2019-08-27 17:09:24 +03:00

34 lines
776 B
Go

package crypto
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestUint160DecodeEncodeAddress(t *testing.T) {
addrs := []string{
"AMLr1CpPQtbEdiJdriX1HpRNMZUwbU2Huj",
"AKtwd3DRXj3nL5kHMUoNsdnsCEVjnuuTFF",
"AMxkaxFVG8Q1BhnB4fjTA5ZmUTEnnTMJMa",
}
for _, addr := range addrs {
val, err := Uint160DecodeAddress(addr)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, addr, AddressFromUint160(val))
}
}
func TestUint160DecodeKnownAddress(t *testing.T) {
address := "AJeAEsmeD6t279Dx4n2HWdUvUmmXQ4iJvP"
val, err := Uint160DecodeAddress(address)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, "b28427088a3729b2536d10122960394e8be6721f", val.ReverseString())
assert.Equal(t, "1f72e68b4e39602912106d53b229378a082784b2", val.String())
}