@@ -15,7 +15,7 @@ import (
15
15
"github.com/golang/protobuf/proto"
16
16
cb "github.com/hyperledger/fabric-protos-go/common"
17
17
pb "github.com/hyperledger/fabric-protos-go/peer"
18
- mockmsp "github.com/hyperledger/fabric/common/mocks/msp"
18
+
19
19
"github.com/hyperledger/fabric/protoutil"
20
20
"github.com/hyperledger/fabric/protoutil/fakes"
21
21
"github.com/stretchr/testify/assert"
@@ -121,8 +121,8 @@ func TestCreateSignedTx(t *testing.T) {
121
121
var err error
122
122
prop := & pb.Proposal {}
123
123
124
- signID , err := mockmsp . NewNoopMsp (). GetDefaultSigningIdentity ()
125
- assert . NoError ( t , err , "Unexpected error getting signing identity" )
124
+ signID := & fakes. SignerSerializer {}
125
+ signID . SerializeReturns ([] byte ( "signer" ), nil )
126
126
signerBytes , err := signID .Serialize ()
127
127
assert .NoError (t , err , "Unexpected error serializing signing identity" )
128
128
@@ -240,8 +240,8 @@ func TestCreateSignedTxStatus(t *testing.T) {
240
240
})
241
241
assert .NoError (t , err )
242
242
243
- signingID , err := mockmsp . NewNoopMsp (). GetDefaultSigningIdentity ()
244
- assert . NoError ( t , err )
243
+ signingID := & fakes. SignerSerializer {}
244
+ signingID . SerializeReturns ([] byte ( "signer" ), nil )
245
245
serializedSigningID , err := signingID .Serialize ()
246
246
assert .NoError (t , err )
247
247
serializedSignatureHeader , err := proto .Marshal (& cb.SignatureHeader {
@@ -343,16 +343,18 @@ func TestGetSignedProposal(t *testing.T) {
343
343
var signedProp * pb.SignedProposal
344
344
var err error
345
345
346
- signID , err := mockmsp .NewNoopMsp ().GetDefaultSigningIdentity ()
347
- assert .NoError (t , err , "Unexpected error getting signing identity" )
346
+ sig := []byte ("signature" )
347
+
348
+ signID := & fakes.SignerSerializer {}
349
+ signID .SignReturns (sig , nil )
348
350
349
351
prop := & pb.Proposal {}
350
352
propBytes , _ := proto .Marshal (prop )
351
353
signedProp , err = protoutil .GetSignedProposal (prop , signID )
352
354
assert .NoError (t , err , "Unexpected error getting signed proposal" )
353
355
assert .Equal (t , propBytes , signedProp .ProposalBytes ,
354
356
"Proposal bytes did not match expected value" )
355
- assert .Equal (t , [] byte ( "signature" ) , signedProp .Signature ,
357
+ assert .Equal (t , sig , signedProp .Signature ,
356
358
"Signature did not match expected value" )
357
359
358
360
_ , err = protoutil .GetSignedProposal (nil , signID )
@@ -400,8 +402,8 @@ func TestMockSignedEndorserProposal2OrPanic(t *testing.T) {
400
402
cis := & pb.ChaincodeInvocationSpec {}
401
403
chainID := "testchannelid"
402
404
sig := []byte ("signature" )
403
- signID , err := mockmsp . NewNoopMsp (). GetDefaultSigningIdentity ()
404
- assert . NoError ( t , err , "Unexpected error getting signing identity" )
405
+ signID := & fakes. SignerSerializer {}
406
+ signID . SignReturns ( sig , nil )
405
407
406
408
signedProp , prop = protoutil .MockSignedEndorserProposal2OrPanic (chainID ,
407
409
& pb.ChaincodeSpec {}, signID )
@@ -410,7 +412,7 @@ func TestMockSignedEndorserProposal2OrPanic(t *testing.T) {
410
412
propBytes , _ := proto .Marshal (prop )
411
413
assert .Equal (t , propBytes , signedProp .ProposalBytes ,
412
414
"Proposal bytes do not match expected value" )
413
- err = proto .Unmarshal (prop .Payload , ccProposal )
415
+ err : = proto .Unmarshal (prop .Payload , ccProposal )
414
416
assert .NoError (t , err , "Expected ChaincodeProposalPayload" )
415
417
err = proto .Unmarshal (ccProposal .Input , cis )
416
418
assert .NoError (t , err , "Expected ChaincodeInvocationSpec" )
0 commit comments