whisper: fix anonymous broadcast drop, add broadcast tests

This commit is contained in:
Péter Szilágyi
2015-04-14 12:12:47 +03:00
parent 4af7743663
commit 5205b2f19b
3 changed files with 105 additions and 30 deletions

View File

@ -11,6 +11,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/ecies"
"github.com/ethereum/go-ethereum/rlp"
)
@ -96,10 +97,14 @@ func (self *Envelope) Open(key *ecdsa.PrivateKey) (msg *Message, err error) {
if key == nil {
return message, nil
}
switch message.decrypt(key) {
err = message.decrypt(key)
switch err {
case nil:
return message, nil
case ecies.ErrInvalidPublicKey: // Payload isn't encrypted
return message, err
default:
return nil, fmt.Errorf("unable to open envelope, decrypt failed: %v", err)
}