status-go/account/address_test.go

25 lines
551 B
Go
Raw Normal View History

package account
import (
"testing"
2020-01-02 09:10:19 +00:00
"github.com/stretchr/testify/require"
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types"
)
func TestCreateAddress(t *testing.T) {
addr, pub, priv, err := CreateAddress()
require.NoError(t, err)
require.Equal(t, types.IsHexAddress(addr), true)
privECDSA, err := crypto.HexToECDSA(priv[2:])
require.NoError(t, err)
pubECDSA := privECDSA.PublicKey
expectedPubStr := types.EncodeHex(crypto.FromECDSAPub(&pubECDSA))
require.Equal(t, expectedPubStr, pub)
}