mirror of
https://github.com/status-im/whisper.git
synced 2025-02-01 13:35:57 +00:00
added nil check
This commit is contained in:
parent
58a79af01a
commit
6abd465f78
@ -79,6 +79,7 @@ func (self *Envelope) Open(prv *ecdsa.PrivateKey) (msg *Message, err error) {
|
||||
if prv != nil {
|
||||
message.Payload, err = crypto.Decrypt(prv, payload)
|
||||
switch err {
|
||||
case nil: // OK
|
||||
case ecies.ErrInvalidPublicKey: // Payload isn't encrypted
|
||||
message.Payload = payload
|
||||
return &message, err
|
||||
|
@ -40,12 +40,11 @@ func TestMessageEncryptDecrypt(t *testing.T) {
|
||||
|
||||
msg1, err := envelope.Open(prv2)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Error(err)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
if !bytes.Equal(msg1.Payload, data) {
|
||||
fmt.Println("encryption error. data did not match")
|
||||
t.FailNow()
|
||||
t.Error("encryption error. data did not match")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user