File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -440,6 +440,9 @@ func (m *SignedGossipMessage) IsSigned() bool {
440
440
// SignedGossipMessage out of it.
441
441
// Returns an error if un-marshaling fails.
442
442
func (e * Envelope ) ToGossipMessage () (* SignedGossipMessage , error ) {
443
+ if e == nil {
444
+ return nil , errors .New ("nil envelope" )
445
+ }
443
446
msg := & GossipMessage {}
444
447
err := proto .Unmarshal (e .Payload , msg )
445
448
if err != nil {
Original file line number Diff line number Diff line change @@ -26,6 +26,12 @@ import (
26
26
"github.com/stretchr/testify/assert"
27
27
)
28
28
29
+ func TestToGossipMessageNilEnvelope (t * testing.T ) {
30
+ memReq := & MembershipRequest {}
31
+ _ , err := memReq .SelfInformation .ToGossipMessage ()
32
+ assert .EqualError (t , err , "nil envelope" )
33
+ }
34
+
29
35
func TestToString (t * testing.T ) {
30
36
// Ensure we don't print the byte content when we
31
37
// log messages.
You can’t perform that action at this time.
0 commit comments