github.com/yimialmonte/fabric@v2.1.1+incompatible/discovery/protoext/signedreq_test.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package protoext_test
     8  
     9  import (
    10  	"testing"
    11  
    12  	"github.com/golang/protobuf/proto"
    13  	"github.com/hyperledger/fabric-protos-go/discovery"
    14  	"github.com/hyperledger/fabric/discovery/protoext"
    15  	"github.com/stretchr/testify/assert"
    16  )
    17  
    18  func TestSignedRequestToRequest(t *testing.T) {
    19  	sr := &discovery.SignedRequest{
    20  		Payload: []byte{0},
    21  	}
    22  	r, err := protoext.SignedRequestToRequest(sr)
    23  	assert.Error(t, err)
    24  
    25  	req := &discovery.Request{}
    26  	b, _ := proto.Marshal(req)
    27  	sr.Payload = b
    28  	r, err = protoext.SignedRequestToRequest(sr)
    29  	assert.NoError(t, err)
    30  	assert.NotNil(t, r)
    31  }