neoneo-go/pkg/crypto/base58_test.go
Roman Khimov 7165b5ab1e base58: add testing from _pkg.dev
And drop implementation in _pkg.dev, as it's redundant. Refs. #307.
2019-08-26 13:32:19 +03:00

32 lines
715 B
Go
Executable file

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