mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-19 16:11:20 +00:00
...
This commit is contained in:
28
state/account_test.go
Normal file
28
state/account_test.go
Normal 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")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user