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.

28 lines
615 B

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. package state
  2. import (
  3. . "github.com/tendermint/tendermint/common"
  4. "testing"
  5. )
  6. func TestSignAndValidate(t *testing.T) {
  7. privAccount := GenPrivAccount()
  8. account := &privAccount.Account
  9. msg := CRandBytes(128)
  10. sig := privAccount.SignBytes(msg)
  11. t.Logf("msg: %X, sig: %X", msg, sig)
  12. // Test the signature
  13. if !account.VerifyBytes(msg, sig) {
  14. t.Errorf("Account message signature verification failed")
  15. }
  16. // Mutate the signature, just one bit.
  17. sig.Bytes[0] ^= byte(0x01)
  18. if account.VerifyBytes(msg, sig) {
  19. t.Errorf("Account message signature verification should have failed but passed instead")
  20. }
  21. }