neo-go/pkg/crypto/base58_test.go

33 lines
715 B
Go
Raw Normal View History

package crypto
2019-02-25 22:44:14 +00:00
import (
"encoding/hex"
"testing"
"github.com/stretchr/testify/assert"
)
func TestBase58Decode(t *testing.T) {
2019-02-25 22:44:14 +00:00
input := "1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX"
data, err := Base58Decode(input)
2019-02-25 22:44:14 +00:00
if err != nil {
t.Fatal(err)
}
expected := "0099bc78ba577a95a11f1a344d4d2ae55f2f857b989ea5e5e2"
actual := hex.EncodeToString(data)
assert.Equal(t, expected, actual)
}
func TestBase58Encode(t *testing.T) {
2019-02-25 22:44:14 +00:00
input := "0099bc78ba577a95a11f1a344d4d2ae55f2f857b989ea5e5e2"
inputBytes, _ := hex.DecodeString(input)
data := Base58Encode(inputBytes)
2019-02-25 22:44:14 +00:00
expected := "F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX" // Removed the 1 as it is not checkEncoding
actual := data
assert.Equal(t, expected, actual)
}