hask: import package from _pkg.dev, make it compile

This commit is contained in:
Roman Khimov 2019-08-23 17:02:42 +03:00
parent 37be2e215c
commit 5c5878968b
3 changed files with 10 additions and 5 deletions

View file

@ -4,7 +4,7 @@ import (
"crypto/sha256" "crypto/sha256"
"io" "io"
"github.com/CityOfZion/neo-go/pkg/wire/util" "github.com/CityOfZion/neo-go/pkg/util"
"golang.org/x/crypto/ripemd160" "golang.org/x/crypto/ripemd160"
) )

View file

@ -15,7 +15,7 @@ func TestSha256(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
expected := "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" expected := "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
actual := hex.EncodeToString(data.Bytes()) // MARK: In the DecodeBytes function, there is a bytes reverse, not sure why? actual := hex.EncodeToString(data.Bytes())
assert.Equal(t, expected, actual) assert.Equal(t, expected, actual)
} }

View file

@ -25,9 +25,8 @@ func Uint256DecodeReverseString(s string) (u Uint256, err error) {
return Uint256DecodeReverseBytes(b) return Uint256DecodeReverseBytes(b)
} }
// Uint256DecodeReverseBytes attempts to decode the given string (in LE representation) into an Uint256. // Uint256DecodeBytes attempts to decode the given string (in BE representation) into an Uint256.
func Uint256DecodeReverseBytes(b []byte) (u Uint256, err error) { func Uint256DecodeBytes(b []byte) (u Uint256, err error) {
b = ArrayReverse(b)
if len(b) != uint256Size { if len(b) != uint256Size {
return u, fmt.Errorf("expected []byte of size %d got %d", uint256Size, len(b)) return u, fmt.Errorf("expected []byte of size %d got %d", uint256Size, len(b))
} }
@ -35,6 +34,12 @@ func Uint256DecodeReverseBytes(b []byte) (u Uint256, err error) {
return u, nil return u, nil
} }
// Uint256DecodeReverseBytes attempts to decode the given string (in LE representation) into an Uint256.
func Uint256DecodeReverseBytes(b []byte) (u Uint256, err error) {
b = ArrayReverse(b)
return Uint256DecodeBytes(b)
}
// Bytes returns a byte slice representation of u. // Bytes returns a byte slice representation of u.
func (u Uint256) Bytes() []byte { func (u Uint256) Bytes() []byte {
return u[:] return u[:]