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.

33 lines
559 B

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