Skip to content

Commit

Permalink
[FAB-5899] unable to use signed install package
Browse files Browse the repository at this point in the history
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 <muralisr@us.ibm.com>
(cherry picked from commit 6ffdc30)
Signed-off-by: Gari Singh <gari.r.singh@gmail.com>
  • Loading branch information
Srinivasan Muralidharan authored and mastersingh24 committed Aug 31, 2017
1 parent c4c977d commit 5f853da
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/endorser/endorser.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,13 @@ func (e *Endorser) disableJavaCCInst(cid *pb.ChaincodeID, cis *pb.ChaincodeInvoc
}

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

cds := ccpack.GetDepSpec()

//finally, if JAVA error out
if cds.ChaincodeSpec.Type == pb.ChaincodeSpec_JAVA {
return fmt.Errorf("Java chaincode is work-in-progress and disabled")
Expand Down
23 changes: 23 additions & 0 deletions core/endorser/endorser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,29 @@ func TestJavaDeploy(t *testing.T) {
chaincode.GetChain().Stop(context.Background(), cccid, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec})
}

func TestJavaCheckWithDifferentPackageTypes(t *testing.T) {
//try SignedChaincodeDeploymentSpec with go chaincode (type 1)
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeId: &pb.ChaincodeID{Name: "gocc", Path: "path/to/cc", Version: "0"}, Input: &pb.ChaincodeInput{Args: [][]byte{[]byte("someargs")}}}
cds := &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec, CodePackage: []byte("some code")}
env := &common.Envelope{Payload: pbutils.MarshalOrPanic(&common.Payload{Data: pbutils.MarshalOrPanic(&pb.SignedChaincodeDeploymentSpec{ChaincodeDeploymentSpec: pbutils.MarshalOrPanic(cds)})})}
//wrap the package in an invocation spec to lscc...
b := pbutils.MarshalOrPanic(env)

lsccCID := &pb.ChaincodeID{Name: "lscc", Version: util.GetSysCCVersion()}
lsccSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_GOLANG, ChaincodeId: lsccCID, Input: &pb.ChaincodeInput{Args: [][]byte{[]byte("install"), b}}}}

e := &Endorser{}
err := e.disableJavaCCInst(lsccCID, lsccSpec)
assert.Nil(t, err)

//now try plain ChaincodeDeploymentSpec...should succeed (go chaincode)
b = pbutils.MarshalOrPanic(cds)

lsccSpec = &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_GOLANG, ChaincodeId: lsccCID, Input: &pb.ChaincodeInput{Args: [][]byte{[]byte("install"), b}}}}
err = e.disableJavaCCInst(lsccCID, lsccSpec)
assert.Nil(t, err)
}

//TestRedeploy - deploy two times, second time should fail but example02 should remain deployed
func TestRedeploy(t *testing.T) {
chainID := util.GetTestChainID()
Expand Down

0 comments on commit 5f853da

Please sign in to comment.