Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
remove payloadType check when unmarhaling
Browse files Browse the repository at this point in the history
  • Loading branch information
yusefnapora committed Dec 9, 2019
1 parent 28bd604 commit 1f29b58
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 15 deletions.
4 changes: 0 additions & 4 deletions routing/state.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package routing

import (
"bytes"
"errors"
"github.com/gogo/protobuf/proto"
"github.com/libp2p/go-libp2p-core/crypto"
Expand Down Expand Up @@ -84,9 +83,6 @@ func UnmarshalSignedRoutingState(envelopeBytes []byte) (*SignedRoutingState, err
// Fails if the signature is invalid, if the envelope has an unexpected payload type,
// or if deserialization of the envelope payload fails.
func SignedRoutingStateFromEnvelope(envelope *crypto.SignedEnvelope) (*SignedRoutingState, error) {
if bytes.Compare(envelope.PayloadType, StateEnvelopePayloadType) != 0 {
return nil, errors.New("unexpected envelope payload type")
}
var msg pb.RoutingStateRecord
err := proto.Unmarshal(envelope.Payload, &msg)
if err != nil {
Expand Down
11 changes: 0 additions & 11 deletions routing/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,4 @@ func TestSignedRoutingStateFromEnvelope(t *testing.T) {
_, err = UnmarshalSignedRoutingState(envBytes)
test.ExpectError(t, err, "unwrapping RoutingState from envelope should fail if envelope was created with wrong domain string")
})

t.Run("unwrapping from signed envelope fails if envelope has wrong payload type", func(t *testing.T) {
stateBytes, err := state.Marshal()
test.AssertNilError(t, err)
payloadType := []byte("wrong-payload-type")
env, err := crypto.MakeEnvelope(priv, StateEnvelopeDomain, payloadType, stateBytes)
test.AssertNilError(t, err)
envBytes, err := env.Marshal()
_, err = UnmarshalSignedRoutingState(envBytes)
test.ExpectError(t, err, "unwrapping RoutingState from envelope should fail if envelope was created with wrong payload type")
})
}

0 comments on commit 1f29b58

Please sign in to comment.