You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

34 lines
557 B

package core
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewKey(t *testing.T) {
_, err := NewKey()
assert.Nil(t, err)
}
func TestAddress(t *testing.T) {
privK, err := NewKey()
assert.Nil(t, err)
addr := AddressFromPrivK(privK)
fmt.Println(addr.String())
}
func TestSignAndVerify(t *testing.T) {
privK, err := NewKey()
assert.Nil(t, err)
// Sign
m := []byte("test")
sig, err := Sign(privK, m)
assert.Nil(t, err)
// Verify
verified := VerifySignature(&privK.PublicKey, m, *sig)
assert.True(t, verified)
}