Skip to content

Commit

Permalink
FAB-1926 add version field to chaincode ID
Browse files Browse the repository at this point in the history
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 <muralisr@us.ibm.com>
  • Loading branch information
Srinivasan Muralidharan committed Feb 8, 2017
1 parent ce8bd1e commit 32ae559
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 70 deletions.
2 changes: 1 addition & 1 deletion peer/chaincode/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func getChaincodeSpecification(cmd *cobra.Command) (*pb.ChaincodeSpec, error) {
chaincodeLang = strings.ToUpper(chaincodeLang)
spec = &pb.ChaincodeSpec{
Type: pb.ChaincodeSpec_Type(pb.ChaincodeSpec_Type_value[chaincodeLang]),
ChaincodeID: &pb.ChaincodeID{Path: chaincodePath, Name: chaincodeName},
ChaincodeID: &pb.ChaincodeID{Path: chaincodePath, Name: chaincodeName, Version: chaincodeVersion},
Input: input,
}
return spec, nil
Expand Down
6 changes: 6 additions & 0 deletions peer/chaincode/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ func createCCInstallPath(path string) (string, error) {

func packageCC(chaincodeBin []byte) ([]byte, error) {
//TODO create proper, secured package, for now return chaincode binary asis
//
//At minimum, the package will contain
// . chaincodeBin
// . serialized Policy
// . hash of the above computed here at install time
// . signature with above
return chaincodeBin, nil
}

Expand Down
15 changes: 15 additions & 0 deletions peer/chaincode/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ func TestInstallCmd(t *testing.T) {
}
}

// TestBadVersion tests generation of install command
func TestBadVersion(t *testing.T) {
fsPath := "/tmp/installtest"

cmd := initInstallTest(fsPath, t)
defer finitInstallTest(fsPath)

args := []string{"-n", "example02", "-p", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02"}
cmd.SetArgs(args)

if err := cmd.Execute(); err == nil {
t.Fatalf("Expected error executing install command for version not specified")
}
}

// TestNonExistentCC non existent chaincode should fail as expected
func TestNonExistentCC(t *testing.T) {
fsPath := "/tmp/installtest"
Expand Down
141 changes: 72 additions & 69 deletions protos/peer/chaincode.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions protos/peer/chaincode.proto
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ message ChaincodeID {
//all other requests will use the name (really a hashcode) generated by
//the deploy transaction
string name = 2;

//user friendly version name for the chaincode
string version = 3;
}

// Carries the chaincode function and its arguments.
Expand Down

0 comments on commit 32ae559

Please sign in to comment.