remove payloadType check when unmarhaling

This commit is contained in:
Yusef Napora 2019-12-09 12:24:34 -05:00
parent f24669b805
commit 9844518f63
2 changed files with 0 additions and 15 deletions

View File

@ -1,7 +1,6 @@
package routing
import (
"bytes"
"errors"
"github.com/gogo/protobuf/proto"
"github.com/libp2p/go-libp2p-core/crypto"
@ -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 {

View File

@ -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")
})
}