diff --git a/bddtests/syschaincode/noop/chaincode.go b/bddtests/syschaincode/noop/chaincode.go index 6a301312ef9..e4cd3db5d84 100644 --- a/bddtests/syschaincode/noop/chaincode.go +++ b/bddtests/syschaincode/noop/chaincode.go @@ -17,7 +17,6 @@ package noop import ( - "bytes" "errors" "github.com/golang/protobuf/proto" @@ -60,18 +59,11 @@ func (t *SystemChaincode) Init(stub shim.ChaincodeStubInterface, function string // Invoke runs an invocation on the system chaincode func (t *SystemChaincode) Invoke(stub shim.ChaincodeStubInterface, function string, args []string) ([]byte, error) { - switch function { - case "execute": - - if len(args) < 1 { - return nil, errors.New("execute operation must include single argument, the base64 encoded form of a byte sequence") - } - logger.Infof("Executing NOOP INVOKE") - return nil, nil - - default: - return nil, errors.New("Unsupported operation") + if len(args) != 1 { + return nil, errors.New("Noop execute operation must have one single argument.") } + logger.Infof("Executing noop invoke.") + return nil, nil } // Query callback representing the query of a chaincode @@ -94,8 +86,11 @@ func (t *SystemChaincode) Query(stub shim.ChaincodeStubInterface, function strin if nil != merr { return nil, merr } - var dataInByteForm = newCCIS.ChaincodeSpec.CtorMsg.Args - return bytes.Join(dataInByteForm, []byte{}), nil + if len(newCCIS.ChaincodeSpec.CtorMsg.Args) < 1 { + return nil, errors.New("The requested transaction is malformed.") + } + var dataInByteForm = newCCIS.ChaincodeSpec.CtorMsg.Args[0] + return dataInByteForm, nil default: return nil, errors.New("Unsupported operation") } diff --git a/bddtests/syschaincode/noop/chaincode_test.go b/bddtests/syschaincode/noop/chaincode_test.go index 7664329a6ac..5b4e80a69d8 100644 --- a/bddtests/syschaincode/noop/chaincode_test.go +++ b/bddtests/syschaincode/noop/chaincode_test.go @@ -61,11 +61,11 @@ func TestInvokeExecuteOneArgReturnsNothing(t *testing.T) { } } -func TestInvokeExecuteMoreArgsReturnsNothing(t *testing.T) { +func TestInvokeExecuteMoreArgsReturnsError(t *testing.T) { var noop = SystemChaincode{mockLedger{}} var res, err = noop.Invoke(nil, "execute", []string{"arg1", "arg2"}) - if res != nil || err != nil { - t.Errorf("Invoke.execute has to return nil with no error.") + if res != nil || err == nil { + t.Errorf("Invoke.execute has to return error when called with more than one arguments.") } }