This commit is contained in:
Jae Kwon
2014-10-03 17:59:54 -07:00
parent 8e452aa0d2
commit 11a79f11e0
3 changed files with 72 additions and 13 deletions

28
state/account_test.go Normal file
View File

@ -0,0 +1,28 @@
package state
import (
. "github.com/tendermint/tendermint/common"
"testing"
)
func TestSignAndValidate(t *testing.T) {
privAccount := GenPrivAccount()
account := &privAccount.Account
msg := RandBytes(128)
sig := privAccount.Sign(msg)
t.Logf("msg: %X, sig: %X", msg, sig)
// Test the signature
if !account.Verify(msg, sig) {
t.Errorf("Account message signature verification failed")
}
// Mutate the signature, just one bit.
sig.Bytes[0] ^= byte(0x01)
if account.Verify(msg, sig) {
t.Errorf("Account message signature verification should have failed but passed instead")
}
}