Skip to content

Commit 5f853da

Browse files
Srinivasan Muralidharanmastersingh24
Srinivasan Muralidharan
authored andcommitted
[FAB-5899] unable to use signed install package
The check for detecting if a chaincode lifecycle operation (install instantiate or upgrade) was on a Java chaincode was expecting a ChaincodeDeploymentSpec (currently only form supported by SDKs). This prevented signed packages installed from CLI from working. This is good to get working in anticipation of full future adoption by SDKs. Change-Id: Iead28f60e13e16048cd01464bd471e9c4d6e4d05 Signed-off-by: Srinivasan Muralidharan <[email protected]> (cherry picked from commit 6ffdc30) Signed-off-by: Gari Singh <[email protected]>
1 parent c4c977d commit 5f853da

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

core/endorser/endorser.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,13 @@ func (e *Endorser) disableJavaCCInst(cid *pb.ChaincodeID, cis *pb.ChaincodeInvoc
190190
}
191191

192192
//the inner dep spec will contain the type
193-
cds, err := putils.GetChaincodeDeploymentSpec(cis.ChaincodeSpec.Input.Args[argNo])
193+
ccpack, err := ccprovider.GetCCPackage(cis.ChaincodeSpec.Input.Args[argNo])
194194
if err != nil {
195195
return err
196196
}
197197

198+
cds := ccpack.GetDepSpec()
199+
198200
//finally, if JAVA error out
199201
if cds.ChaincodeSpec.Type == pb.ChaincodeSpec_JAVA {
200202
return fmt.Errorf("Java chaincode is work-in-progress and disabled")

core/endorser/endorser_test.go

+23
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,29 @@ func TestJavaDeploy(t *testing.T) {
368368
chaincode.GetChain().Stop(context.Background(), cccid, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec})
369369
}
370370

371+
func TestJavaCheckWithDifferentPackageTypes(t *testing.T) {
372+
//try SignedChaincodeDeploymentSpec with go chaincode (type 1)
373+
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeId: &pb.ChaincodeID{Name: "gocc", Path: "path/to/cc", Version: "0"}, Input: &pb.ChaincodeInput{Args: [][]byte{[]byte("someargs")}}}
374+
cds := &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec, CodePackage: []byte("some code")}
375+
env := &common.Envelope{Payload: pbutils.MarshalOrPanic(&common.Payload{Data: pbutils.MarshalOrPanic(&pb.SignedChaincodeDeploymentSpec{ChaincodeDeploymentSpec: pbutils.MarshalOrPanic(cds)})})}
376+
//wrap the package in an invocation spec to lscc...
377+
b := pbutils.MarshalOrPanic(env)
378+
379+
lsccCID := &pb.ChaincodeID{Name: "lscc", Version: util.GetSysCCVersion()}
380+
lsccSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_GOLANG, ChaincodeId: lsccCID, Input: &pb.ChaincodeInput{Args: [][]byte{[]byte("install"), b}}}}
381+
382+
e := &Endorser{}
383+
err := e.disableJavaCCInst(lsccCID, lsccSpec)
384+
assert.Nil(t, err)
385+
386+
//now try plain ChaincodeDeploymentSpec...should succeed (go chaincode)
387+
b = pbutils.MarshalOrPanic(cds)
388+
389+
lsccSpec = &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_GOLANG, ChaincodeId: lsccCID, Input: &pb.ChaincodeInput{Args: [][]byte{[]byte("install"), b}}}}
390+
err = e.disableJavaCCInst(lsccCID, lsccSpec)
391+
assert.Nil(t, err)
392+
}
393+
371394
//TestRedeploy - deploy two times, second time should fail but example02 should remain deployed
372395
func TestRedeploy(t *testing.T) {
373396
chainID := util.GetTestChainID()

0 commit comments

Comments
 (0)