diff --git a/bddtests/features/endorser.feature b/bddtests/features/endorser.feature index d5aabc1d08e..1526318a1c1 100644 --- a/bddtests/features/endorser.feature +++ b/bddtests/features/endorser.feature @@ -24,7 +24,7 @@ Feature: Endorser And I register with CA supplying username "binhn" and secret "7avZQLwcUe9q" on peers: | vp0 | - When user "binhn" creates a chaincode spec "cc_spec" of type "GOLANG" for chaincode "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" with args + When user "binhn" creates a chaincode spec "cc_spec" of type "GOLANG" for chaincode "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd" with args | funcName | arg1 | arg2 | arg3 | arg4 | | init | a | 100 | b | 200 | And user "binhn" creates a deployment spec "cc_deploy_spec" using chaincode spec "cc_spec" and devops on peer "vp0" @@ -49,7 +49,7 @@ Feature: Endorser And I register with CA supplying username "binhn" and secret "7avZQLwcUe9q" on peers: | vp0 | - When user "binhn" creates a chaincode spec of type "GOLANG" for chaincode "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" aliased as "cc_spec" with args + When user "binhn" creates a chaincode spec of type "GOLANG" for chaincode "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd" aliased as "cc_spec" with args | funcName | arg1 | arg2 | arg3 | arg4 | | init | a | 100 | b | 200 | And user "binhn" sets ESCC to "my_escc" for chaincode spec "cc_spec" @@ -72,7 +72,7 @@ Feature: Endorser And I register with CA supplying username "binhn" and secret "7avZQLwcUe9q" on peers: | vp0 | - When user "binhn" creates a chaincode spec of type "GOLANG" for chaincode "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" aliased as "cc_spec" with args + When user "binhn" creates a chaincode spec of type "GOLANG" for chaincode "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd" aliased as "cc_spec" with args | funcName | arg1 | arg2 | arg3 | arg4 | | init | a | 100 | b | 200 | And user "binhn" sets VSCC to "my_vscc" for chaincode spec "cc_spec" diff --git a/bddtests/steps/endorser_util.py b/bddtests/steps/endorser_util.py index dd3d3a7da5f..8fdadbdb5e1 100644 --- a/bddtests/steps/endorser_util.py +++ b/bddtests/steps/endorser_util.py @@ -150,12 +150,12 @@ def getEndorserStubs(context, composeServices, directory, nodeAdminTuple): return stubs def getExample02ChaincodeSpec(): - return getChaincodeSpec("GOLANG", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "example02", ["init","a","100","b","200"]) + return getChaincodeSpec("GOLANG", "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd", "example02", ["init","a","100","b","200"]) def _createDeploymentSpecAsFile(ccSpec, outputPath): - '''peer chaincode package -n myCC -c '{"Args":["init","a","100","b","200"]}' -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 --logging-level=DEBUG test.file''' + '''peer chaincode package -n myCC -c '{"Args":["init","a","100","b","200"]}' -p github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd --logging-level=DEBUG test.file''' myEnv = os.environ.copy() myEnv['CORE_PEER_MSPCONFIGPATH'] = "./../sampleconfig/msp" nameArgs = ["-n", ccSpec.chaincode_id.name] diff --git a/core/chaincode/multichains_test.go b/core/chaincode/multichains_test.go index 0c15bed16b1..d9fb7f496d4 100644 --- a/core/chaincode/multichains_test.go +++ b/core/chaincode/multichains_test.go @@ -39,7 +39,7 @@ func TestExecuteInvokeOnManyChains(t *testing.T) { var ctxt = context.Background() - url := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" + url := "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd" chaincodeID := &pb.ChaincodeID{Name: "example02", Path: url, Version: "0"} args := []string{"a", "b", "10"} diff --git a/core/chaincode/platforms/golang/platform_test.go b/core/chaincode/platforms/golang/platform_test.go index 5bc674250bd..55b7567c067 100644 --- a/core/chaincode/platforms/golang/platform_test.go +++ b/core/chaincode/platforms/golang/platform_test.go @@ -139,7 +139,7 @@ func Test_DeploymentPayload(t *testing.T) { platform := &Platform{} spec := &pb.ChaincodeSpec{ ChaincodeId: &pb.ChaincodeID{ - Path: "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", + Path: "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd", }, } diff --git a/core/chaincode/upgrade_test.go b/core/chaincode/upgrade_test.go index 2c659a1f28c..f876aaa659a 100644 --- a/core/chaincode/upgrade_test.go +++ b/core/chaincode/upgrade_test.go @@ -179,7 +179,7 @@ func TestUpgradeCC(t *testing.T) { //now upgrade to example02 which takes the same args as example01 but inits state vars //and also allows query. - url = "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" + url = "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd" //Note ccName hasn't changed... chaincodeID = &pb.ChaincodeID{Name: ccName, Path: url, Version: "1"} @@ -232,7 +232,7 @@ func TestInvalUpgradeCC(t *testing.T) { var ctxt = context.Background() ccName := "mycc" - url := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" + url := "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd" f := "init" args := util.ToChaincodeArgs(f, "a", "100", "b", "200") diff --git a/core/common/ccprovider/ccinfocache_test.go b/core/common/ccprovider/ccinfocache_test.go index 07385aac630..6cfad00d37b 100644 --- a/core/common/ccprovider/ccinfocache_test.go +++ b/core/common/ccprovider/ccinfocache_test.go @@ -79,7 +79,7 @@ func (m *mockCCInfoFSStorageMgrImpl) GetChaincode(ccname string, ccversion strin func TestCCInfoCache(t *testing.T) { ccname := "foo" ccver := "1.0" - ccpath := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" + ccpath := "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd" ccinfoFs := &mockCCInfoFSStorageMgrImpl{CCMap: map[string]CCPackage{}} cccache := NewCCInfoCache(ccinfoFs) @@ -134,7 +134,7 @@ func TestCCInfoCache(t *testing.T) { func TestPutChaincode(t *testing.T) { ccname := "" ccver := "1.0" - ccpath := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" + ccpath := "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd" ccinfoFs := &mockCCInfoFSStorageMgrImpl{CCMap: map[string]CCPackage{}} NewCCInfoCache(ccinfoFs) @@ -164,7 +164,7 @@ func TestPutChaincode(t *testing.T) { func TestCCInfoFSPeerInstance(t *testing.T) { ccname := "bar" ccver := "1.0" - ccpath := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" + ccpath := "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd" // the cc data is not yet in the cache _, err := GetChaincodeFromFS(ccname, ccver) diff --git a/core/container/dockercontroller/dockercontroller_test.go b/core/container/dockercontroller/dockercontroller_test.go index 614e70ac8c5..f04ce0d61ff 100644 --- a/core/container/dockercontroller/dockercontroller_test.go +++ b/core/container/dockercontroller/dockercontroller_test.go @@ -131,7 +131,7 @@ func Test_Start(t *testing.T) { err = dvm.Start(ctx, ccid, args, env, files, nil, nil) testerr(t, err, false) - chaincodePath := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example01" + chaincodePath := "github.com/hyperledger/fabric/examples/chaincode/go/example01/cmd" spec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_GOLANG, ChaincodeId: &pb.ChaincodeID{Name: "ex01", Path: chaincodePath}, Input: &pb.ChaincodeInput{Args: util.ToChaincodeArgs("f")}} diff --git a/core/container/vm_test.go b/core/container/vm_test.go index c3d6d9f0bd4..09581580ae2 100644 --- a/core/container/vm_test.go +++ b/core/container/vm_test.go @@ -53,7 +53,7 @@ func TestVM_BuildImage_ChaincodeLocal(t *testing.T) { return } // Build the spec - chaincodePath := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example01" + chaincodePath := "github.com/hyperledger/fabric/examples/chaincode/go/example01/cmd" spec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_GOLANG, ChaincodeId: &pb.ChaincodeID{Name: "ex01", Path: chaincodePath}, Input: &pb.ChaincodeInput{Args: util.ToChaincodeArgs("f")}} diff --git a/core/scc/lscc/lscc_test.go b/core/scc/lscc/lscc_test.go index a6f2815f6c1..14ee6af66b1 100644 --- a/core/scc/lscc/lscc_test.go +++ b/core/scc/lscc/lscc_test.go @@ -112,7 +112,7 @@ func TestInstall(t *testing.T) { res = stub.MockInvokeWithSignedProposal("1", [][]byte{[]byte(INSTALL)}, nil) assert.NotEqual(t, res.Status, int32(shim.OK), res.Message) - path := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" + path := "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd" testInstall(t, "example02", "0", path, false, "", "Alice", scc, stub) testInstall(t, "example02-2", "1.0", path, false, "", "Alice", scc, stub) @@ -163,7 +163,7 @@ func testInstall(t *testing.T, ccname string, version string, path string, creat } func TestDeploy(t *testing.T) { - path := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" + path := "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd" testDeploy(t, "example02", "0", path, false, false, true, "", nil, nil) testDeploy(t, "example02", "1.0", path, false, false, true, "", nil, nil) @@ -303,7 +303,7 @@ func testDeploy(t *testing.T, ccname string, version string, path string, forceB // TestUpgrade tests the upgrade function with various inputs for basic use cases func TestUpgrade(t *testing.T) { - path := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" + path := "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd" testUpgrade(t, "example02", "0", "example02", "1", path, "", nil, nil) testUpgrade(t, "example02", "0", "example02", "", path, EmptyVersionErr("example02").Error(), nil, nil) diff --git a/core/scc/vscc/validator_onevalidsignature_test.go b/core/scc/vscc/validator_onevalidsignature_test.go index 75a26b386c0..565ee0db9d7 100644 --- a/core/scc/vscc/validator_onevalidsignature_test.go +++ b/core/scc/vscc/validator_onevalidsignature_test.go @@ -821,7 +821,7 @@ func TestAlreadyDeployed(t *testing.T) { ccname := "mycc" ccver := "1" - path := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" + path := "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd" ppath := lccctestpath + "/" + ccname + "." + ccver @@ -1160,7 +1160,7 @@ func TestValidateUpgradeOK(t *testing.T) { ccname := "mycc" ccver := "1" - path := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" + path := "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd" ppath := lccctestpath + "/" + ccname + "." + ccver @@ -1241,7 +1241,7 @@ func TestInvalidateUpgradeBadVersion(t *testing.T) { ccname := "mycc" ccver := "1" - path := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" + path := "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd" ppath := lccctestpath + "/" + ccname + "." + ccver @@ -1320,7 +1320,7 @@ func TestValidateUpgradeWithPoliciesOK(t *testing.T) { ccname := "mycc" ccver := "1" - path := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" + path := "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd" ppath := lccctestpath + "/" + ccname + "." + ccver @@ -1421,7 +1421,7 @@ func validateUpgradeWithNewFailAllIP(t *testing.T, v11capability, expecterr bool ccname := "mycc" ccver := "1" - path := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" + path := "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd" ppath := lccctestpath + "/" + ccname + "." + ccver os.Remove(ppath) @@ -1515,7 +1515,7 @@ func TestValidateUpgradeWithPoliciesFail(t *testing.T) { ccname := "mycc" ccver := "1" - path := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" + path := "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd" ppath := lccctestpath + "/" + ccname + "." + ccver diff --git a/docs/source/chaincode4noah.rst b/docs/source/chaincode4noah.rst index 32d94ca86e9..38f807e963d 100644 --- a/docs/source/chaincode4noah.rst +++ b/docs/source/chaincode4noah.rst @@ -88,7 +88,7 @@ To create a signed chaincode package, use the following command: .. code:: bash - peer chaincode package -n mycc -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -v 0 -s -S -i "AND('OrgA.admin')" ccpack.out + peer chaincode package -n mycc -p github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd -v 0 -s -S -i "AND('OrgA.admin')" ccpack.out The ``-s`` option creates a package that can be signed by multiple owners as opposed to simply creating a raw CDS. When ``-s`` is specified, the ``-S`` diff --git a/docs/source/commands/peerchaincode.md b/docs/source/commands/peerchaincode.md index 802bffba755..661e0eda833 100644 --- a/docs/source/commands/peerchaincode.md +++ b/docs/source/commands/peerchaincode.md @@ -138,7 +138,7 @@ Here are some examples of the `peer chaincode install` command: * To install chaincode named `mycc` at version `1.0`: ``` - peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 + peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd . . @@ -411,7 +411,7 @@ Here are some examples of the `peer chaincode list ` command: peer chaincode list --installed Get installed chaincodes on peer: - Name: mycc, Version: 1.0, Path: github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02, Id: 8cc2730fdafd0b28ef734eac12b29df5fc98ad98bdb1b7e0ef96265c3d893d61 + Name: mycc, Version: 1.0, Path: github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd, Id: 8cc2730fdafd0b28ef734eac12b29df5fc98ad98bdb1b7e0ef96265c3d893d61 2018-02-22 17:07:13.476 UTC [main] main -> INFO 001 Exiting..... ``` @@ -426,7 +426,7 @@ Here are some examples of the `peer chaincode list ` command: peer chaincode list --instantiated -C mychannel Get instantiated chaincodes on channel mychannel: - Name: mycc, Version: 1.0, Path: github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02, Escc: escc, Vscc: vscc + Name: mycc, Version: 1.0, Path: github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd, Escc: escc, Vscc: vscc 2018-02-22 17:07:42.969 UTC [main] main -> INFO 001 Exiting..... ``` @@ -510,7 +510,7 @@ deployment spec, signs the package using the local MSP, and outputs it as `ccpack.out`: * ``` - peer chaincode package ccpack.out -n mycc -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -v 1.1 -s -S + peer chaincode package ccpack.out -n mycc -p github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd -v 1.1 -s -S . . diff --git a/docs/source/install_instantiate.rst b/docs/source/install_instantiate.rst index 3719ea9536d..93b3f092489 100644 --- a/docs/source/install_instantiate.rst +++ b/docs/source/install_instantiate.rst @@ -74,7 +74,7 @@ of ``v0`` onto ``peer0``. .. code:: bash - CORE_PEER_ADDRESS=peer0:7051 peer chaincode install -n mycc -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -v v0 + CORE_PEER_ADDRESS=peer0:7051 peer chaincode install -n mycc -p github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd -v v0 Instantiate the chaincode on the channel from the remote CLI ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -86,7 +86,7 @@ instantiation will initialize the chaincode with key value pairs of .. code:: bash - CORE_PEER_ADDRESS=peer0:7051 peer chaincode instantiate -o orderer:5005 -C myc -n mycc -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -v v0 -c '{"Args":["init","a","100","b","200"]}' + CORE_PEER_ADDRESS=peer0:7051 peer chaincode instantiate -o orderer:5005 -C myc -n mycc -v v0 -c '{"Args":["init","a","100","b","200"]}' **Continue operating within your second terminal for the remainder of the commands** @@ -132,7 +132,7 @@ read/write operations. .. code:: bash - CORE_PEER_ADDRESS=peer1:7051 peer chaincode install -n mycc -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -v v0 + CORE_PEER_ADDRESS=peer1:7051 peer chaincode install -n mycc -p github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd -v v0 | **Note**: The initial instantiation applies to all peers in the channel, and is affected upon any peer that has the chaincode diff --git a/docs/source/peer-chaincode-devmode.rst b/docs/source/peer-chaincode-devmode.rst index c1bd3f8d3df..8bef06a2756 100644 --- a/docs/source/peer-chaincode-devmode.rst +++ b/docs/source/peer-chaincode-devmode.rst @@ -67,9 +67,9 @@ Start the chaincode :: - cd examples/chaincode/go/chaincode_example02 - go build - CORE_CHAINCODE_LOGLEVEL=debug CORE_PEER_ADDRESS=127.0.0.1:7052 CORE_CHAINCODE_ID_NAME=mycc:0 ./chaincode_example02 + cd examples/chaincode/go/chaincode_example02/cmd + go build -o example02 + CORE_CHAINCODE_LOGLEVEL=debug CORE_PEER_ADDRESS=127.0.0.1:7052 CORE_CHAINCODE_ID_NAME=mycc:0 ./example02 The chaincode is started with peer and chaincode logs indicating successful registration with the peer. Note that at this stage the chaincode is not associated with any channel. This is done in subsequent steps @@ -84,7 +84,7 @@ mode. :: - peer chaincode install -n mycc -v 0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 + peer chaincode install -n mycc -v 0 -p github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd Once installed, the chaincode is ready to be instantiated. diff --git a/examples/chaincode/go/chaincode_example01/chaincode_example01.go b/examples/chaincode/go/example01/chaincode.go similarity index 64% rename from examples/chaincode/go/chaincode_example01/chaincode_example01.go rename to examples/chaincode/go/example01/chaincode.go index 302f2d98313..f2d9f1d6bb4 100644 --- a/examples/chaincode/go/chaincode_example01/chaincode_example01.go +++ b/examples/chaincode/go/example01/chaincode.go @@ -1,20 +1,10 @@ /* -Copyright IBM Corp. 2016 All Rights Reserved. +Copyright IBM Corp. All Rights Reserved. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +SPDX-License-Identifier: Apache-2.0 */ -package main +package example01 import ( "fmt" @@ -25,8 +15,7 @@ import ( ) // SimpleChaincode example simple Chaincode implementation -type SimpleChaincode struct { -} +type SimpleChaincode struct{} var A, B string var Aval, Bval, X int @@ -53,19 +42,6 @@ func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response { } fmt.Printf("Aval = %d, Bval = %d\n", Aval, Bval) - /************ - // Write the state to the ledger - err = stub.PutState(A, []byte(strconv.Itoa(Aval)) - if err != nil { - return nil, err - } - - stub.PutState(B, []byte(strconv.Itoa(Bval)) - err = stub.PutState(B, []byte(strconv.Itoa(Bval)) - if err != nil { - return nil, err - } - ************/ return shim.Success(nil) } @@ -95,10 +71,3 @@ func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response { return shim.Error("Invalid invoke function name. Expecting \"invoke\"") } - -func main() { - err := shim.Start(new(SimpleChaincode)) - if err != nil { - fmt.Printf("Error starting Simple chaincode: %s", err) - } -} diff --git a/examples/chaincode/go/example01/cmd/main.go b/examples/chaincode/go/example01/cmd/main.go new file mode 100644 index 00000000000..96e6db659ae --- /dev/null +++ b/examples/chaincode/go/example01/cmd/main.go @@ -0,0 +1,21 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package main + +import ( + "fmt" + + "github.com/hyperledger/fabric/core/chaincode/shim" + "github.com/hyperledger/fabric/examples/chaincode/go/example01" +) + +func main() { + err := shim.Start(new(example01.SimpleChaincode)) + if err != nil { + fmt.Printf("Error starting Simple chaincode: %s", err) + } +} diff --git a/examples/chaincode/go/chaincode_example02/chaincode_example02.go b/examples/chaincode/go/example02/chaincode.go similarity index 85% rename from examples/chaincode/go/chaincode_example02/chaincode_example02.go rename to examples/chaincode/go/example02/chaincode.go index eb6f430b7d1..87629f40662 100644 --- a/examples/chaincode/go/chaincode_example02/chaincode_example02.go +++ b/examples/chaincode/go/example02/chaincode.go @@ -1,20 +1,10 @@ /* -Copyright IBM Corp. 2016 All Rights Reserved. +Copyright IBM Corp. All Rights Reserved. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +SPDX-License-Identifier: Apache-2.0 */ -package main +package example02 import ( "fmt" @@ -184,10 +174,3 @@ func (t *SimpleChaincode) query(stub shim.ChaincodeStubInterface, args []string) fmt.Printf("Query Response:%s\n", jsonResp) return shim.Success(Avalbytes) } - -func main() { - err := shim.Start(new(SimpleChaincode)) - if err != nil { - fmt.Printf("Error starting Simple chaincode: %s", err) - } -} diff --git a/examples/chaincode/go/chaincode_example02/chaincode_example02_test.go b/examples/chaincode/go/example02/chaincode_test.go similarity index 81% rename from examples/chaincode/go/chaincode_example02/chaincode_example02_test.go rename to examples/chaincode/go/example02/chaincode_test.go index c6c8ed7f343..72345d76579 100644 --- a/examples/chaincode/go/chaincode_example02/chaincode_example02_test.go +++ b/examples/chaincode/go/example02/chaincode_test.go @@ -1,19 +1,10 @@ /* -Copyright IBM Corp. 2016 All Rights Reserved. +Copyright IBM Corp. All Rights Reserved. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +SPDX-License-Identifier: Apache-2.0 */ -package main + +package example02 import ( "fmt" diff --git a/examples/chaincode/go/example02/cmd/main.go b/examples/chaincode/go/example02/cmd/main.go new file mode 100644 index 00000000000..ab27c8529fb --- /dev/null +++ b/examples/chaincode/go/example02/cmd/main.go @@ -0,0 +1,21 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package main + +import ( + "fmt" + + "github.com/hyperledger/fabric/core/chaincode/shim" + "github.com/hyperledger/fabric/examples/chaincode/go/example02" +) + +func main() { + err := shim.Start(new(example02.SimpleChaincode)) + if err != nil { + fmt.Printf("Error starting Simple chaincode: %s", err) + } +} diff --git a/examples/chaincode/go/chaincode_example03/chaincode_example03.go b/examples/chaincode/go/example03/chaincode.go similarity index 73% rename from examples/chaincode/go/chaincode_example03/chaincode_example03.go rename to examples/chaincode/go/example03/chaincode.go index d667a8225dc..fe627d8c722 100644 --- a/examples/chaincode/go/chaincode_example03/chaincode_example03.go +++ b/examples/chaincode/go/example03/chaincode.go @@ -1,21 +1,11 @@ /* -Copyright IBM Corp. 2016 All Rights Reserved. +Copyright IBM Corp. All Rights Reserved. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +SPDX-License-Identifier: Apache-2.0 */ // This program is an erroneous chaincode program that attempts to put state in query context - query should return error -package main +package example03 import ( "fmt" @@ -26,8 +16,7 @@ import ( ) // SimpleChaincode example simple Chaincode implementation -type SimpleChaincode struct { -} +type SimpleChaincode struct{} // Init takes a string and int. These are stored as a key/value pair in the state func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response { @@ -91,10 +80,3 @@ func (t *SimpleChaincode) query(stub shim.ChaincodeStubInterface, args []string) return shim.Success(nil) } - -func main() { - err := shim.Start(new(SimpleChaincode)) - if err != nil { - fmt.Printf("Error starting chaincode: %s", err) - } -} diff --git a/examples/chaincode/go/chaincode_example03/chaincode_example03_test.go b/examples/chaincode/go/example03/chaincode_test.go similarity index 70% rename from examples/chaincode/go/chaincode_example03/chaincode_example03_test.go rename to examples/chaincode/go/example03/chaincode_test.go index 812650e078b..a65c87a9eb6 100644 --- a/examples/chaincode/go/chaincode_example03/chaincode_example03_test.go +++ b/examples/chaincode/go/example03/chaincode_test.go @@ -1,19 +1,10 @@ /* -Copyright IBM Corp. 2016 All Rights Reserved. +Copyright IBM Corp. All Rights Reserved. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +SPDX-License-Identifier: Apache-2.0 */ -package main + +package example03 import ( "fmt" diff --git a/examples/chaincode/go/example03/cmd/main.go b/examples/chaincode/go/example03/cmd/main.go new file mode 100644 index 00000000000..cb4569715c5 --- /dev/null +++ b/examples/chaincode/go/example03/cmd/main.go @@ -0,0 +1,21 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package main + +import ( + "fmt" + + "github.com/hyperledger/fabric/core/chaincode/shim" + "github.com/hyperledger/fabric/examples/chaincode/go/example03" +) + +func main() { + err := shim.Start(new(example03.SimpleChaincode)) + if err != nil { + fmt.Printf("Error starting chaincode: %s", err) + } +} diff --git a/examples/chaincode/go/chaincode_example04/chaincode_example04.go b/examples/chaincode/go/example04/chaincode.go similarity index 84% rename from examples/chaincode/go/chaincode_example04/chaincode_example04.go rename to examples/chaincode/go/example04/chaincode.go index b874ad7306e..dd3d5d58576 100644 --- a/examples/chaincode/go/chaincode_example04/chaincode_example04.go +++ b/examples/chaincode/go/example04/chaincode.go @@ -1,20 +1,10 @@ /* -Copyright IBM Corp. 2016 All Rights Reserved. +Copyright IBM Corp. All Rights Reserved. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +SPDX-License-Identifier: Apache-2.0 */ -package main +package example04 import ( "fmt" @@ -27,8 +17,7 @@ import ( // This chaincode is a test for chaincode invoking another chaincode - invokes chaincode_example02 // SimpleChaincode example simple Chaincode implementation -type SimpleChaincode struct { -} +type SimpleChaincode struct{} func toChaincodeArgs(args ...string) [][]byte { bargs := make([][]byte, len(args)) @@ -165,10 +154,3 @@ func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response { return shim.Error("Invalid invoke function name. Expecting \"invoke\" \"query\"") } - -func main() { - err := shim.Start(new(SimpleChaincode)) - if err != nil { - fmt.Printf("Error starting Simple chaincode: %s", err) - } -} diff --git a/examples/chaincode/go/chaincode_example04/chaincode_example04_test.go b/examples/chaincode/go/example04/chaincode_test.go similarity index 80% rename from examples/chaincode/go/chaincode_example04/chaincode_example04_test.go rename to examples/chaincode/go/example04/chaincode_test.go index 9d252e2d818..dfb3df4650a 100644 --- a/examples/chaincode/go/chaincode_example04/chaincode_example04_test.go +++ b/examples/chaincode/go/example04/chaincode_test.go @@ -1,26 +1,17 @@ /* -Copyright IBM Corp. 2016 All Rights Reserved. +Copyright IBM Corp. All Rights Reserved. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +SPDX-License-Identifier: Apache-2.0 */ -package main + +package example04 import ( "fmt" "testing" "github.com/hyperledger/fabric/core/chaincode/shim" - ex02 "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" + "github.com/hyperledger/fabric/examples/chaincode/go/example02" ) // this is the response to any successful Invoke() on chaincode_example04 @@ -97,7 +88,7 @@ func TestExample04_Invoke(t *testing.T) { chaincodeToInvoke := "ex02" - ccEx2 := new(ex02.SimpleChaincode) + ccEx2 := new(example02.SimpleChaincode) stubEx2 := shim.NewMockStub(chaincodeToInvoke, ccEx2) checkInit(t, stubEx2, [][]byte{[]byte("init"), []byte("a"), []byte("111"), []byte("b"), []byte("222")}) stub.MockPeerChaincode(chaincodeToInvoke, stubEx2) diff --git a/examples/chaincode/go/example04/cmd/main.go b/examples/chaincode/go/example04/cmd/main.go new file mode 100644 index 00000000000..46857a6af27 --- /dev/null +++ b/examples/chaincode/go/example04/cmd/main.go @@ -0,0 +1,21 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package main + +import ( + "fmt" + + "github.com/hyperledger/fabric/core/chaincode/shim" + "github.com/hyperledger/fabric/examples/chaincode/go/example04" +) + +func main() { + err := shim.Start(new(example04.SimpleChaincode)) + if err != nil { + fmt.Printf("Error starting Simple chaincode: %s", err) + } +} diff --git a/examples/chaincode/go/chaincode_example05/chaincode_example05.go b/examples/chaincode/go/example05/chaincode.go similarity index 88% rename from examples/chaincode/go/chaincode_example05/chaincode_example05.go rename to examples/chaincode/go/example05/chaincode.go index 35ef5074d25..45909dd46aa 100644 --- a/examples/chaincode/go/chaincode_example05/chaincode_example05.go +++ b/examples/chaincode/go/example05/chaincode.go @@ -1,20 +1,10 @@ /* -Copyright IBM Corp. 2016 All Rights Reserved. +Copyright IBM Corp. All Rights Reserved. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +SPDX-License-Identifier: Apache-2.0 */ -package main +package example05 import ( "fmt" @@ -27,8 +17,7 @@ import ( // This chaincode is a test for chaincode querying another chaincode - invokes chaincode_example02 and computes the sum of a and b and stores it as state // SimpleChaincode example simple Chaincode implementation -type SimpleChaincode struct { -} +type SimpleChaincode struct{} func toChaincodeArgs(args ...string) [][]byte { bargs := make([][]byte, len(args)) @@ -206,10 +195,3 @@ func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response { return shim.Success([]byte("Invalid invoke function name. Expecting \"invoke\" \"query\"")) } - -func main() { - err := shim.Start(new(SimpleChaincode)) - if err != nil { - fmt.Printf("Error starting Simple chaincode: %s", err) - } -} diff --git a/examples/chaincode/go/chaincode_example05/chaincode_example05_test.go b/examples/chaincode/go/example05/chaincode_test.go similarity index 83% rename from examples/chaincode/go/chaincode_example05/chaincode_example05_test.go rename to examples/chaincode/go/example05/chaincode_test.go index 1f6d3047b67..a9a82773555 100644 --- a/examples/chaincode/go/chaincode_example05/chaincode_example05_test.go +++ b/examples/chaincode/go/example05/chaincode_test.go @@ -1,26 +1,17 @@ /* -Copyright IBM Corp. 2016 All Rights Reserved. +Copyright IBM Corp. All Rights Reserved. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +SPDX-License-Identifier: Apache-2.0 */ -package main + +package example05 import ( "fmt" "testing" "github.com/hyperledger/fabric/core/chaincode/shim" - ex02 "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" + "github.com/hyperledger/fabric/examples/chaincode/go/example02" ) var chaincodeName = "ex02" @@ -89,7 +80,7 @@ func TestExample05_Query(t *testing.T) { scc := new(SimpleChaincode) stub := shim.NewMockStub("ex05", scc) - ccEx2 := new(ex02.SimpleChaincode) + ccEx2 := new(example02.SimpleChaincode) stubEx2 := shim.NewMockStub(chaincodeName, ccEx2) checkInit(t, stubEx2, [][]byte{[]byte("init"), []byte("a"), []byte("111"), []byte("b"), []byte("222")}) stub.MockPeerChaincode(chaincodeName, stubEx2) @@ -104,7 +95,7 @@ func TestExample05_Invoke(t *testing.T) { scc := new(SimpleChaincode) stub := shim.NewMockStub("ex05", scc) - ccEx2 := new(ex02.SimpleChaincode) + ccEx2 := new(example02.SimpleChaincode) stubEx2 := shim.NewMockStub(chaincodeName, ccEx2) checkInit(t, stubEx2, [][]byte{[]byte("init"), []byte("a"), []byte("222"), []byte("b"), []byte("333")}) stub.MockPeerChaincode(chaincodeName, stubEx2) diff --git a/examples/chaincode/go/example05/cmd/main.go b/examples/chaincode/go/example05/cmd/main.go new file mode 100644 index 00000000000..ee0449658bf --- /dev/null +++ b/examples/chaincode/go/example05/cmd/main.go @@ -0,0 +1,21 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package main + +import ( + "fmt" + + "github.com/hyperledger/fabric/core/chaincode/shim" + "github.com/hyperledger/fabric/examples/chaincode/go/example05" +) + +func main() { + err := shim.Start(new(example05.SimpleChaincode)) + if err != nil { + fmt.Printf("Error starting Simple chaincode: %s", err) + } +} diff --git a/examples/chaincode/java/SimpleSample/src/main/java/example/SimpleSample.java b/examples/chaincode/java/SimpleSample/src/main/java/example/SimpleSample.java index 54fb0499806..0baa113f921 100644 --- a/examples/chaincode/java/SimpleSample/src/main/java/example/SimpleSample.java +++ b/examples/chaincode/java/SimpleSample/src/main/java/example/SimpleSample.java @@ -28,7 +28,7 @@ /** *

Classic "transfer" sample chaincode

(java implementation of chaincode_example02.go) + * "https://github.com/hyperledger/fabric/blob/master/examples/chaincode/go/example02">example02) * * @author Sergey Pomytkin spomytkin@gmail.com * diff --git a/examples/e2e_cli/docker-compose-e2e.yaml b/examples/e2e_cli/docker-compose-e2e.yaml index d5b57833986..e15d998e09b 100644 --- a/examples/e2e_cli/docker-compose-e2e.yaml +++ b/examples/e2e_cli/docker-compose-e2e.yaml @@ -13,10 +13,10 @@ services: - FABRIC_CA_SERVER_CA_NAME=ca-org1 - FABRIC_CA_SERVER_TLS_ENABLED=true - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem - - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/2628c774d6def25e2bf6147c30f25fe76469d63d257965ac867544acd090148c_sk + - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/792e3fb9e2e4f7f9e2a84f5368e6e61d4b96954156484b46dc2ace946e7f7f2d_sk ports: - "7054:7054" - command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/2628c774d6def25e2bf6147c30f25fe76469d63d257965ac867544acd090148c_sk -b admin:adminpw -d' + command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/792e3fb9e2e4f7f9e2a84f5368e6e61d4b96954156484b46dc2ace946e7f7f2d_sk -b admin:adminpw -d' volumes: - ./crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config container_name: ca_peerOrg1 @@ -28,10 +28,10 @@ services: - FABRIC_CA_SERVER_CA_NAME=ca-org2 - FABRIC_CA_SERVER_TLS_ENABLED=true - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem - - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/3f39c678fc9b1f79cddb94f1e896cc3c487aa25c2ebf8b7f3e0205c2d21a37ec_sk + - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/a7728108f88fdaf430ee1faf1390bd8071c9f3154d5a7ac2e2368ef6d51a61f0_sk ports: - "8054:7054" - command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/3f39c678fc9b1f79cddb94f1e896cc3c487aa25c2ebf8b7f3e0205c2d21a37ec_sk -b admin:adminpw -d' + command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/a7728108f88fdaf430ee1faf1390bd8071c9f3154d5a7ac2e2368ef6d51a61f0_sk -b admin:adminpw -d' volumes: - ./crypto-config/peerOrganizations/org2.example.com/ca/:/etc/hyperledger/fabric-ca-server-config container_name: ca_peerOrg2 diff --git a/examples/e2e_cli/end-to-end.rst b/examples/e2e_cli/end-to-end.rst index 4bf8f37184b..4f160e88468 100644 --- a/examples/e2e_cli/end-to-end.rst +++ b/examples/e2e_cli/end-to-end.rst @@ -661,7 +661,7 @@ Install the sample go code onto one of the four peer nodes .. code:: bash - peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 + peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd Instantiate chaincode and define the endorsement policy ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -677,7 +677,7 @@ The command is: # be sure to replace the $CHANNEL_NAME environment variable # if you did not install your chaincode with a name of mycc, then modify that argument as well - peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/cacerts/ca.example.com-cert.pem -C $CHANNEL_NAME -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Args":["init","a", "100", "b","200"]}' -P "OR ('Org1MSP.member','Org2MSP.member')" + peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/cacerts/ca.example.com-cert.pem -C $CHANNEL_NAME -n mycc -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "OR ('Org1MSP.member','Org2MSP.member')" See the `endorsement policies `__ @@ -755,7 +755,7 @@ chaincode: # be sure to modify the $CHANNEL_NAME variable accordingly for the instantiate command peer chaincode install -o orderer.example.com:7050 -n marbles -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/marbles02 - peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/cacerts/ca.example.com-cert.pem -C $CHANNEL_NAME -n marbles -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/marbles02 -c '{"Args":["init"]}' -P "OR ('Org0MSP.member','Org1MSP.member')" + peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/cacerts/ca.example.com-cert.pem -C $CHANNEL_NAME -n marbles -v 1.0 -c '{"Args":["init"]}' -P "OR ('Org0MSP.member','Org1MSP.member')" - Create some marbles and move them around: diff --git a/examples/e2e_cli/scripts/script.sh b/examples/e2e_cli/scripts/script.sh index a233f13f7cc..1f39df4c942 100755 --- a/examples/e2e_cli/scripts/script.sh +++ b/examples/e2e_cli/scripts/script.sh @@ -143,7 +143,7 @@ joinChannel () { installChaincode () { PEER=$1 setGlobals $PEER - peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 >&log.txt + peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd >&log.txt res=$? cat log.txt verifyResult $res "Chaincode installation on remote peer PEER$PEER has Failed" diff --git a/peer/chaincode/install_test.go b/peer/chaincode/install_test.go index 527ab2dcb2f..fbd852b88e2 100644 --- a/peer/chaincode/install_test.go +++ b/peer/chaincode/install_test.go @@ -66,7 +66,7 @@ func TestBadVersion(t *testing.T) { cmd, _ := initInstallTest(fsPath, t) defer cleanupInstallTest(fsPath) - args := []string{"-n", "example02", "-p", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02"} + args := []string{"-n", "example02", "-p", "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd"} cmd.SetArgs(args) if err := cmd.Execute(); err == nil { @@ -181,7 +181,7 @@ func installEx02() error { cmd := installCmd(mockCF) addFlags(cmd) - args := []string{"-n", "example02", "-p", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "-v", "anotherversion"} + args := []string{"-n", "example02", "-p", "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd", "-v", "anotherversion"} cmd.SetArgs(args) if err := cmd.Execute(); err != nil { diff --git a/peer/chaincode/upgrade_test.go b/peer/chaincode/upgrade_test.go index 8b9a83599a3..89410e60a02 100644 --- a/peer/chaincode/upgrade_test.go +++ b/peer/chaincode/upgrade_test.go @@ -70,13 +70,13 @@ func TestUpgradeCmd(t *testing.T) { cmd := upgradeCmd(mockCF) addFlags(cmd) - args := []string{"-n", "example02", "-p", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", + args := []string{"-n", "example02", "-p", "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd", "-v", "anotherversion", "-c", "{\"Function\":\"init\",\"Args\": [\"param\",\"1\"]}"} cmd.SetArgs(args) err = cmd.Execute() assert.Error(t, err, "'peer chaincode upgrade' command should have failed without -C flag") - args = []string{"-C", "mychannel", "-n", "example02", "-p", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", + args = []string{"-C", "mychannel", "-n", "example02", "-p", "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd", "-v", "anotherversion", "-c", "{\"Function\":\"init\",\"Args\": [\"param\",\"1\"]}"} cmd.SetArgs(args) err = cmd.Execute() @@ -108,7 +108,7 @@ func TestUpgradeCmdEndorseFail(t *testing.T) { cmd := upgradeCmd(mockCF) addFlags(cmd) - args := []string{"-C", "mychannel", "-n", "example02", "-p", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", + args := []string{"-C", "mychannel", "-n", "example02", "-p", "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd", "-v", "anotherversion", "-c", "{\"Function\":\"init\",\"Args\": [\"param\",\"1\"]}"} cmd.SetArgs(args) @@ -149,7 +149,7 @@ func TestUpgradeCmdSendTXFail(t *testing.T) { cmd := upgradeCmd(mockCF) addFlags(cmd) - args := []string{"-C", "mychannel", "-n", "example02", "-p", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "-v", "anotherversion", "-c", "{\"Function\":\"init\",\"Args\": [\"param\",\"1\"]}"} + args := []string{"-C", "mychannel", "-n", "example02", "-p", "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd", "-v", "anotherversion", "-c", "{\"Function\":\"init\",\"Args\": [\"param\",\"1\"]}"} cmd.SetArgs(args) expectErrMsg := sendErr.Error() @@ -179,7 +179,7 @@ func TestUpgradeCmdWithNilCF(t *testing.T) { cmd := upgradeCmd(nil) addFlags(cmd) - args := []string{"-C", "mychannel", "-n", "example02", "-p", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", + args := []string{"-C", "mychannel", "-n", "example02", "-p", "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd", "-v", "anotherversion", "-c", "{\"Function\":\"init\",\"Args\": [\"param\",\"1\"]}"} cmd.SetArgs(args) err := cmd.Execute() diff --git a/test/feature/orderer.feature b/test/feature/orderer.feature index c3829674e9b..e40343d9c97 100644 --- a/test/feature/orderer.feature +++ b/test/feature/orderer.feature @@ -75,7 +75,7 @@ Scenario: FAB-3851: Message Payloads Greater than 1MB Scenario: FAB-4686: Test taking down all kafka brokers and bringing back last 3 Given I have a bootstrapped fabric network of type kafka And I wait "60" seconds - When a user deploys chaincode at path "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" with ["init","a","1000","b","2000"] with name "mycc" + When a user deploys chaincode at path "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd" with ["init","a","1000","b","2000"] with name "mycc" And I wait "30" seconds Then the chaincode is deployed When a user invokes on the chaincode named "mycc" with args ["invoke","a","b","10"] diff --git a/test/feature/peer.feature b/test/feature/peer.feature index 3d016bdd685..e310e1e5617 100644 --- a/test/feature/peer.feature +++ b/test/feature/peer.feature @@ -21,7 +21,7 @@ Feature: Peer Service Scenario Outline: FAB-3505: Test chaincode example02 deploy, invoke, and query Given I have a bootstrapped fabric network of type And I wait "" seconds - When a user deploys chaincode at path "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" with ["init","a","1000","b","2000"] with name "mycc" + When a user deploys chaincode at path "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd" with ["init","a","1000","b","2000"] with name "mycc" And I wait "5" seconds Then the chaincode is deployed When a user queries on the chaincode named "mycc" with args ["query","a"] diff --git a/test/feature/steps/endorser_impl.py b/test/feature/steps/endorser_impl.py index e5209d9fa68..20cbae06bd1 100644 --- a/test/feature/steps/endorser_impl.py +++ b/test/feature/steps/endorser_impl.py @@ -51,7 +51,7 @@ def step_impl(context, path, args): @when(u'a user deploys chaincode') def step_impl(context): deploy_impl(context, - "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", + "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd", '["init", "a", "100" , "b", "200"]', "mycc", "peer0.org1.example.com", diff --git a/test/regression/daily/chaincodeTests/fabricFeatureChaincodes/e2e_test_example02.sh b/test/regression/daily/chaincodeTests/fabricFeatureChaincodes/e2e_test_example02.sh index 82c1600189c..7c322cfab47 100755 --- a/test/regression/daily/chaincodeTests/fabricFeatureChaincodes/e2e_test_example02.sh +++ b/test/regression/daily/chaincodeTests/fabricFeatureChaincodes/e2e_test_example02.sh @@ -69,7 +69,7 @@ installChaincode () { do PEER=$i setGlobals $PEER - peer chaincode install -n $CHAINCODE_NAME$ch -v 1 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 >>$LOG_FILE + peer chaincode install -n $CHAINCODE_NAME$ch -v 1 -p github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd >>$LOG_FILE res=$? verifyResult $res "Chaincode '$CHAINCODE_NAME$ch' installation on remote peer PEER$PEER has Failed" echo "===================== Chaincode '$CHAINCODE_NAME$ch' is installed on PEER$PEER successfully===================== " >>$LOG_FILE