Skip to content

Commit 32ae559

Browse files
author
Srinivasan Muralidharan
committed
FAB-1926 add version field to chaincode ID
https://jira.hyperledger.org/browse/FAB-1926 Adds version to chaincode ID proto specification and uses it in the installer. Change-Id: If9f3fa7c6c5661b73a9aacbc2b74a0d2b39adf7f Signed-off-by: Srinivasan Muralidharan <[email protected]>
1 parent ce8bd1e commit 32ae559

File tree

5 files changed

+97
-70
lines changed

5 files changed

+97
-70
lines changed

peer/chaincode/common.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func getChaincodeSpecification(cmd *cobra.Command) (*pb.ChaincodeSpec, error) {
8686
chaincodeLang = strings.ToUpper(chaincodeLang)
8787
spec = &pb.ChaincodeSpec{
8888
Type: pb.ChaincodeSpec_Type(pb.ChaincodeSpec_Type_value[chaincodeLang]),
89-
ChaincodeID: &pb.ChaincodeID{Path: chaincodePath, Name: chaincodeName},
89+
ChaincodeID: &pb.ChaincodeID{Path: chaincodePath, Name: chaincodeName, Version: chaincodeVersion},
9090
Input: input,
9191
}
9292
return spec, nil

peer/chaincode/install.go

+6
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ func createCCInstallPath(path string) (string, error) {
6767

6868
func packageCC(chaincodeBin []byte) ([]byte, error) {
6969
//TODO create proper, secured package, for now return chaincode binary asis
70+
//
71+
//At minimum, the package will contain
72+
// . chaincodeBin
73+
// . serialized Policy
74+
// . hash of the above computed here at install time
75+
// . signature with above
7076
return chaincodeBin, nil
7177
}
7278

peer/chaincode/install_test.go

+15
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,21 @@ func TestInstallCmd(t *testing.T) {
7575
}
7676
}
7777

78+
// TestBadVersion tests generation of install command
79+
func TestBadVersion(t *testing.T) {
80+
fsPath := "/tmp/installtest"
81+
82+
cmd := initInstallTest(fsPath, t)
83+
defer finitInstallTest(fsPath)
84+
85+
args := []string{"-n", "example02", "-p", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02"}
86+
cmd.SetArgs(args)
87+
88+
if err := cmd.Execute(); err == nil {
89+
t.Fatalf("Expected error executing install command for version not specified")
90+
}
91+
}
92+
7893
// TestNonExistentCC non existent chaincode should fail as expected
7994
func TestNonExistentCC(t *testing.T) {
8095
fsPath := "/tmp/installtest"

protos/peer/chaincode.pb.go

+72-69
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/peer/chaincode.proto

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ message ChaincodeID {
4444
//all other requests will use the name (really a hashcode) generated by
4545
//the deploy transaction
4646
string name = 2;
47+
48+
//user friendly version name for the chaincode
49+
string version = 3;
4750
}
4851

4952
// Carries the chaincode function and its arguments.

0 commit comments

Comments
 (0)