github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/discovery/protoext/signedreq_test.go (about) 1 /* 2 Copyright hechain. 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/hechain20/hechain/discovery/protoext" 14 "github.com/hyperledger/fabric-protos-go/discovery" 15 "github.com/stretchr/testify/require" 16 ) 17 18 func TestSignedRequestToRequest(t *testing.T) { 19 sr := &discovery.SignedRequest{ 20 Payload: []byte{0}, 21 } 22 _, err := protoext.SignedRequestToRequest(sr) 23 require.Error(t, err) 24 25 req := &discovery.Request{} 26 b, _ := proto.Marshal(req) 27 sr.Payload = b 28 r, err := protoext.SignedRequestToRequest(sr) 29 require.NoError(t, err) 30 require.NotNil(t, r) 31 }