Skip to content

Commit cfa02a4

Browse files
committed
Re-enable CAR test
We upgrade to the v0.10.1 release of chaintool which properly supports the latest fabric. This allows us to re-enable the car unit-test to ensure things do not break in the future. We also add a feature which allows us to overide the version of chaintool at the command-line, which was helpful in formulating the development of the fixes for chaintool as well as the ultimate release of v0.10.1. To use, simply set $CHAINTOOL_URL on the command-line for the build. Helpful tip: it supports file:/// schema. Change-Id: I952e147d9bfe7836517cb5b08f42a12493be05b6 Signed-off-by: Greg Haskins <[email protected]>
1 parent 1f33384 commit cfa02a4

File tree

3 files changed

+27
-29
lines changed

3 files changed

+27
-29
lines changed

Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ PKGNAME = github.com/$(PROJECT_NAME)
4848
GO_LDFLAGS = -X $(PKGNAME)/common/metadata.Version=$(PROJECT_VERSION)
4949
CGO_FLAGS = CGO_CFLAGS=" "
5050
ARCH=$(shell uname -m)
51-
CHAINTOOL_RELEASE=v0.10.0
51+
CHAINTOOL_RELEASE=v0.10.1
5252
BASEIMAGE_RELEASE=$(shell cat ./.baseimage-release)
5353

54+
CHAINTOOL_URL ?= https://github.com/hyperledger/fabric-chaintool/releases/download/$(CHAINTOOL_RELEASE)/chaintool
55+
5456
export GO_LDFLAGS
5557

5658
EXECUTABLES = go docker git curl
@@ -124,7 +126,7 @@ linter: testenv
124126
%/chaintool: Makefile
125127
@echo "Installing chaintool"
126128
@mkdir -p $(@D)
127-
curl -L https://github.com/hyperledger/fabric-chaintool/releases/download/$(CHAINTOOL_RELEASE)/chaintool > $@
129+
curl -L $(CHAINTOOL_URL) > $@
128130
chmod +x $@
129131

130132
# We (re)build a package within a docker context but persist the $GOPATH/pkg

core/chaincode/platforms/car/test/car_test.go

+23-27
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,34 @@ import (
2020
"os"
2121
"testing"
2222

23-
//"github.com/hyperledger/fabric/common/util"
23+
"github.com/hyperledger/fabric/common/util"
2424
"github.com/hyperledger/fabric/core/config"
25-
//"github.com/hyperledger/fabric/core/container"
26-
//pb "github.com/hyperledger/fabric/protos/peer"
25+
"github.com/hyperledger/fabric/core/container"
26+
pb "github.com/hyperledger/fabric/protos/peer"
2727
)
2828

2929
func TestMain(m *testing.M) {
3030
config.SetupTestConfig("../../../../../peer")
3131
os.Exit(m.Run())
3232
}
3333

34-
// Disable this for change chaincode interface temporarily.
35-
// TODO: Update java chaincode interface and enable this.
36-
//func TestCar_BuildImage(t *testing.T) {
37-
// //Skipping the test till chaintool is fixed for changint CtorMsg to Input
38-
// t.Skip()
39-
// vm, err := container.NewVM()
40-
41-
// if err != nil {
42-
// t.Errorf("Error getting VM: %s", err)
43-
// return
44-
// }
45-
// // Build the spec
46-
// cwd, err := os.Getwd()
47-
// if err != nil {
48-
// t.Errorf("Error getting CWD: %s", err)
49-
// return
50-
// }
51-
52-
// chaincodePath := cwd + "/org.hyperledger.chaincode.example02-0.1-SNAPSHOT.car"
53-
// spec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_CAR, ChaincodeID: &pb.ChaincodeID{Name: "cartest", Path: chaincodePath}, Input: &pb.ChaincodeInput{Args: util.ToChaincodeArgs("f")}}
54-
// if _, err := vm.BuildChaincodeContainer(spec); err != nil {
55-
// t.Error(err)
56-
// }
57-
//}
34+
func TestCar_BuildImage(t *testing.T) {
35+
vm, err := container.NewVM()
36+
37+
if err != nil {
38+
t.Errorf("Error getting VM: %s", err)
39+
return
40+
}
41+
// Build the spec
42+
cwd, err := os.Getwd()
43+
if err != nil {
44+
t.Errorf("Error getting CWD: %s", err)
45+
return
46+
}
47+
48+
chaincodePath := cwd + "/org.hyperledger.chaincode.example02-0.1-SNAPSHOT.car"
49+
spec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_CAR, ChaincodeID: &pb.ChaincodeID{Name: "cartest", Path: chaincodePath}, Input: &pb.ChaincodeInput{Args: util.ToChaincodeArgs("f")}}
50+
if _, err := vm.BuildChaincodeContainer(spec); err != nil {
51+
t.Error(err)
52+
}
53+
}

0 commit comments

Comments
 (0)