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

  1. package core
  2. import (
  3. "fmt"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestNewKey(t *testing.T) {
  8. _, err := NewKey()
  9. assert.Nil(t, err)
  10. }
  11. func TestAddress(t *testing.T) {
  12. privK, err := NewKey()
  13. assert.Nil(t, err)
  14. addr := AddressFromPrivK(privK)
  15. fmt.Println(addr.String())
  16. }
  17. func TestSignAndVerify(t *testing.T) {
  18. privK, err := NewKey()
  19. assert.Nil(t, err)
  20. // Sign
  21. m := []byte("test")
  22. sig, err := Sign(privK, m)
  23. assert.Nil(t, err)
  24. // Verify
  25. verified := VerifySignature(&privK.PublicKey, m, *sig)
  26. assert.True(t, verified)
  27. }