Skip to content

Commit

Permalink
Merge "[FAB-11584] Make java cc not experimental"
Browse files Browse the repository at this point in the history
  • Loading branch information
denyeart authored and Gerrit Code Review committed Aug 26, 2018
2 parents 6d2e053 + f42a5f9 commit 8df0555
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 214 deletions.
56 changes: 0 additions & 56 deletions core/endorser/endorser.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,57 +192,6 @@ func (e *Endorser) SanitizeUserCDS(userCDS *pb.ChaincodeDeploymentSpec) (*pb.Cha
return sanitizedCDS, nil
}

// TO BE REMOVED WHEN JAVA CC IS ENABLED
// disableJavaCCInst if trying to install, instantiate or upgrade Java CC
func (e *Endorser) DisableJavaCCInst(cid *pb.ChaincodeID, cis *pb.ChaincodeInvocationSpec) error {
// if not lscc we don't care
if cid.Name != "lscc" {
return nil
}

// non-nil spec ? leave it to callers to handle error if this is an error
if cis.ChaincodeSpec == nil || cis.ChaincodeSpec.Input == nil {
return nil
}

// should at least have a command arg, leave it to callers if this is an error
if len(cis.ChaincodeSpec.Input.Args) < 1 {
return nil
}

var argNo int
switch string(cis.ChaincodeSpec.Input.Args[0]) {
case "install":
argNo = 1
case "deploy", "upgrade":
argNo = 2
default:
// what else can it be ? leave it caller to handle it if error
return nil
}

if argNo >= len(cis.ChaincodeSpec.Input.Args) {
return errors.Errorf("too few arguments passed. expected %d", argNo)
}

if JavaEnabled() {
endorserLogger.Debug("java chaincode enabled")
} else {
endorserLogger.Debug("java chaincode disabled")
// finally, if JAVA not enabled error out
isjava, err := e.s.IsJavaCC(cis.ChaincodeSpec.Input.Args[argNo])
if err != nil {
return err
}
if isjava {
return errors.New("Java chaincode is work-in-progress and disabled")
}
}

// not a java install, instantiate or upgrade op
return nil
}

// SimulateProposal simulates the proposal by calling the chaincode
func (e *Endorser) SimulateProposal(txParams *ccprovider.TransactionParams, cid *pb.ChaincodeID) (ccprovider.ChaincodeDefinition, *pb.Response, []byte, *pb.ChaincodeEvent, error) {
endorserLogger.Debugf("[%s][%s] Entry chaincode: %s", txParams.ChannelID, shorttxid(txParams.TxID), cid)
Expand All @@ -255,11 +204,6 @@ func (e *Endorser) SimulateProposal(txParams *ccprovider.TransactionParams, cid
return nil, nil, nil, nil, err
}

// disable Java install,instantiate,upgrade for now
if err = e.DisableJavaCCInst(cid, cis); err != nil {
return nil, nil, nil, nil, err
}

var cdLedger ccprovider.ChaincodeDefinition
var version string

Expand Down
97 changes: 0 additions & 97 deletions core/endorser/endorser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,75 +381,6 @@ func TestEndorserLSCCDeploySysCC(t *testing.T) {
assert.Equal(t, "attempting to deploy a system chaincode barf/testchainid", pResp.Response.Message)
}

func TestEndorserLSCCJava1(t *testing.T) {
if endorser.JavaEnabled() {
t.Skip("Java chaincode is supported")
}

es := endorser.NewEndorserServer(pvtEmptyDistributor, &em.MockSupport{
GetApplicationConfigBoolRv: true,
GetApplicationConfigRv: &mc.MockApplication{CapabilitiesRv: &mc.MockApplicationCapabilities{}},
IsJavaRV: true,
GetTransactionByIDErr: errors.New(""),
ChaincodeDefinitionRv: &ccprovider.ChaincodeData{Escc: "ESCC"},
ExecuteResp: &pb.Response{Status: 200, Payload: utils.MarshalOrPanic(&pb.ProposalResponse{Response: &pb.Response{}})},
GetTxSimulatorRv: &mockccprovider.MockTxSim{
GetTxSimulationResultsRv: &ledger.TxSimulationResults{
PubSimulationResults: &rwset.TxReadWriteSet{},
},
},
}, platforms.NewRegistry(&golang.Platform{}))

cds := utils.MarshalOrPanic(
&pb.ChaincodeDeploymentSpec{
ChaincodeSpec: &pb.ChaincodeSpec{
ChaincodeId: &pb.ChaincodeID{Name: "barf"},
Type: pb.ChaincodeSpec_JAVA,
},
},
)
signedProp := getSignedPropWithCHIdAndArgs(util.GetTestChainID(), "lscc", "0", [][]byte{[]byte("deploy"), []byte("a"), cds}, t)

pResp, err := es.ProcessProposal(context.Background(), signedProp)
assert.NoError(t, err)
assert.EqualValues(t, 500, pResp.Response.Status)
assert.Equal(t, "Java chaincode is work-in-progress and disabled", pResp.Response.Message)
}

func TestEndorserLSCCJava2(t *testing.T) {
if endorser.JavaEnabled() {
t.Skip("Java chaincode is supported")
}

es := endorser.NewEndorserServer(pvtEmptyDistributor, &em.MockSupport{
GetApplicationConfigBoolRv: true,
GetApplicationConfigRv: &mc.MockApplication{CapabilitiesRv: &mc.MockApplicationCapabilities{}},
IsJavaErr: errors.New(""),
GetTransactionByIDErr: errors.New(""),
ChaincodeDefinitionRv: &ccprovider.ChaincodeData{Escc: "ESCC"},
ExecuteResp: &pb.Response{Status: 200, Payload: utils.MarshalOrPanic(&pb.ProposalResponse{Response: &pb.Response{}})},
GetTxSimulatorRv: &mockccprovider.MockTxSim{
GetTxSimulationResultsRv: &ledger.TxSimulationResults{
PubSimulationResults: &rwset.TxReadWriteSet{},
},
},
}, platforms.NewRegistry(&golang.Platform{}))

cds := utils.MarshalOrPanic(
&pb.ChaincodeDeploymentSpec{
ChaincodeSpec: &pb.ChaincodeSpec{
ChaincodeId: &pb.ChaincodeID{Name: "barf"},
Type: pb.ChaincodeSpec_JAVA,
},
},
)
signedProp := getSignedPropWithCHIdAndArgs(util.GetTestChainID(), "lscc", "0", [][]byte{[]byte("deploy"), []byte("a"), cds}, t)

pResp, err := es.ProcessProposal(context.Background(), signedProp)
assert.NoError(t, err)
assert.EqualValues(t, 500, pResp.Response.Status)
}

func TestEndorserGoodPathWEvents(t *testing.T) {
m := &mock.Mock{}
m.On("Sign", mock.Anything).Return([]byte{1, 2, 3, 4, 5}, nil)
Expand Down Expand Up @@ -610,34 +541,6 @@ func TestSimulateProposal(t *testing.T) {
assert.Error(t, err)
}

func TestEndorserJavaChecks(t *testing.T) {
if endorser.JavaEnabled() {
t.Skip("Java chaincode is supported")
}

es := endorser.NewEndorserServer(pvtEmptyDistributor, &em.MockSupport{
GetApplicationConfigBoolRv: true,
GetApplicationConfigRv: &mc.MockApplication{CapabilitiesRv: &mc.MockApplicationCapabilities{}},
GetTransactionByIDErr: errors.New(""),
ChaincodeDefinitionRv: &ccprovider.ChaincodeData{Escc: "ESCC"},
ExecuteResp: &pb.Response{Status: 200, Payload: utils.MarshalOrPanic(&pb.ProposalResponse{Response: &pb.Response{}})},
GetTxSimulatorRv: &mockccprovider.MockTxSim{
GetTxSimulationResultsRv: &ledger.TxSimulationResults{
PubSimulationResults: &rwset.TxReadWriteSet{},
},
},
}, platforms.NewRegistry(&golang.Platform{}))

err := es.DisableJavaCCInst(&pb.ChaincodeID{Name: "lscc"}, &pb.ChaincodeInvocationSpec{})
assert.NoError(t, err)
err = es.DisableJavaCCInst(&pb.ChaincodeID{Name: "lscc"}, &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{Input: &pb.ChaincodeInput{}}})
assert.NoError(t, err)
err = es.DisableJavaCCInst(&pb.ChaincodeID{Name: "lscc"}, &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{Input: &pb.ChaincodeInput{Args: [][]byte{[]byte("foo")}}}})
assert.NoError(t, err)
err = es.DisableJavaCCInst(&pb.ChaincodeID{Name: "lscc"}, &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{Input: &pb.ChaincodeInput{Args: [][]byte{[]byte("install")}}}})
assert.Error(t, err)
}

func TestEndorserAcquireTxSimulator(t *testing.T) {
tc := []struct {
name string
Expand Down
13 changes: 0 additions & 13 deletions core/endorser/java.go

This file was deleted.

13 changes: 0 additions & 13 deletions core/endorser/nojava.go

This file was deleted.

2 changes: 1 addition & 1 deletion integration/java_chaincode/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var components *nwo.Components

var _ = SynchronizedBeforeSuite(func() []byte {
components = &nwo.Components{}
components.Build("-tags", "\"experimental\"")
components.Build()

payload, err := json.Marshal(components)
Expect(err).NotTo(HaveOccurred())
Expand Down
8 changes: 0 additions & 8 deletions peer/chaincode/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,6 @@ func getChaincodeSpec(cmd *cobra.Command) (*pb.ChaincodeSpec, error) {
}

chaincodeLang = strings.ToUpper(chaincodeLang)
if javaEnabled() {
logger.Debug("java chaincode enabled")
} else {
logger.Debug("java chaincode disabled")
if pb.ChaincodeSpec_Type_value[chaincodeLang] == int32(pb.ChaincodeSpec_JAVA) {
return nil, errors.New("java chaincode is work-in-progress and disabled")
}
}
spec = &pb.ChaincodeSpec{
Type: pb.ChaincodeSpec_Type(pb.ChaincodeSpec_Type_value[chaincodeLang]),
ChaincodeId: &pb.ChaincodeID{Path: chaincodePath, Name: chaincodeName, Version: chaincodeVersion},
Expand Down
13 changes: 0 additions & 13 deletions peer/chaincode/java.go

This file was deleted.

13 changes: 0 additions & 13 deletions peer/chaincode/nojava.go

This file was deleted.

0 comments on commit 8df0555

Please sign in to comment.