@@ -331,6 +331,7 @@ func testDeploy(t *testing.T, ccname string, version string, path string, forceB
331
331
res := stub .MockInit ("1" , nil )
332
332
assert .Equal (t , res .Status , int32 (shim .OK ), res .Message )
333
333
}
334
+ stub .ChannelID = chainid
334
335
335
336
identityDeserializer := & policymocks.MockIdentityDeserializer {[]byte ("Alice" ), []byte ("msg1" )}
336
337
policyManagerGetter := & policymocks.MockChannelPolicyManagerGetter {
@@ -343,7 +344,7 @@ func testDeploy(t *testing.T, ccname string, version string, path string, forceB
343
344
identityDeserializer ,
344
345
& policymocks.MockMSPPrincipalGetter {Principal : []byte ("Alice" )},
345
346
)
346
- sProp , _ := utils .MockSignedEndorserProposalOrPanic ("" , & pb.ChaincodeSpec {}, []byte ("Alice" ), []byte ("msg1" ))
347
+ sProp , _ := utils .MockSignedEndorserProposalOrPanic (chainid , & pb.ChaincodeSpec {}, []byte ("Alice" ), []byte ("msg1" ))
347
348
identityDeserializer .Msg = sProp .ProposalBytes
348
349
sProp .Signature = sProp .ProposalBytes
349
350
@@ -374,6 +375,8 @@ func testDeploy(t *testing.T, ccname string, version string, path string, forceB
374
375
if expectedErrorMsg == "" {
375
376
assert .Equal (t , res .Status , int32 (shim .OK ), res .Message )
376
377
378
+ mockAclProvider .Reset ()
379
+ mockAclProvider .On ("CheckACL" , resources .Lscc_GetInstantiatedChaincodes , chainid , sProp ).Return (nil )
377
380
args = [][]byte {[]byte (GETCHAINCODES )}
378
381
res = stub .MockInvokeWithSignedProposal ("1" , args , sProp )
379
382
assert .Equal (t , res .Status , int32 (shim .OK ), res .Message )
@@ -649,29 +652,25 @@ func TestGETCHAINCODES(t *testing.T) {
649
652
scc := New (NewMockProvider (), mockAclProvider )
650
653
scc .support = & lscc.MockSupport {}
651
654
stub := shim .NewMockStub ("lscc" , scc )
655
+ stub .ChannelID = "test"
652
656
res := stub .MockInit ("1" , nil )
653
657
assert .Equal (t , res .Status , int32 (shim .OK ), res .Message )
654
658
655
659
res = stub .MockInvokeWithSignedProposal ("1" , [][]byte {[]byte (GETCHAINCODES ), []byte ("barf" )}, nil )
656
660
assert .NotEqual (t , res .Status , int32 (shim .OK ), res .Message )
657
661
658
- identityDeserializer := & policymocks.MockIdentityDeserializer {[]byte ("Alice" ), []byte ("msg1" )}
659
- policyManagerGetter := & policymocks.MockChannelPolicyManagerGetter {
660
- Managers : map [string ]policies.Manager {
661
- "test" : & policymocks.MockChannelPolicyManager {MockPolicy : & policymocks.MockPolicy {Deserializer : identityDeserializer }},
662
- },
663
- }
664
- scc .policyChecker = policy .NewPolicyChecker (
665
- policyManagerGetter ,
666
- identityDeserializer ,
667
- & policymocks.MockMSPPrincipalGetter {Principal : []byte ("Alice" )},
668
- )
669
- sProp , _ := utils .MockSignedEndorserProposalOrPanic ("" , & pb.ChaincodeSpec {}, []byte ("Bob" ), []byte ("msg1" ))
670
- identityDeserializer .Msg = sProp .ProposalBytes
662
+ sProp , _ := utils .MockSignedEndorserProposalOrPanic ("test" , & pb.ChaincodeSpec {}, []byte ("Bob" ), []byte ("msg1" ))
671
663
sProp .Signature = sProp .ProposalBytes
672
664
673
- res = stub .MockInvokeWithSignedProposal ("1" , [][]byte {[]byte (GETCHAINCODES )}, nil )
665
+ mockAclProvider .Reset ()
666
+ mockAclProvider .On ("CheckACL" , resources .Lscc_GetInstantiatedChaincodes , "test" , sProp ).Return (errors .New ("ACL Error" ))
667
+ res = stub .MockInvokeWithSignedProposal ("1" , [][]byte {[]byte (GETCHAINCODES )}, sProp )
674
668
assert .NotEqual (t , res .Status , int32 (shim .OK ), res .Message )
669
+
670
+ mockAclProvider .Reset ()
671
+ mockAclProvider .On ("CheckACL" , resources .Lscc_GetInstantiatedChaincodes , "test" , sProp ).Return (nil )
672
+ res = stub .MockInvokeWithSignedProposal ("1" , [][]byte {[]byte (GETCHAINCODES )}, sProp )
673
+ assert .Equal (t , res .Status , int32 (shim .OK ), res .Message )
675
674
}
676
675
677
676
func TestGETINSTALLEDCHAINCODES (t * testing.T ) {
0 commit comments