Skip to content

Commit

Permalink
Re-enable CAR test
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ghaskins committed Feb 1, 2017
1 parent 1f33384 commit cfa02a4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 29 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ PKGNAME = github.com/$(PROJECT_NAME)
GO_LDFLAGS = -X $(PKGNAME)/common/metadata.Version=$(PROJECT_VERSION)
CGO_FLAGS = CGO_CFLAGS=" "
ARCH=$(shell uname -m)
CHAINTOOL_RELEASE=v0.10.0
CHAINTOOL_RELEASE=v0.10.1
BASEIMAGE_RELEASE=$(shell cat ./.baseimage-release)

CHAINTOOL_URL ?= https://github.com/hyperledger/fabric-chaintool/releases/download/$(CHAINTOOL_RELEASE)/chaintool

export GO_LDFLAGS

EXECUTABLES = go docker git curl
Expand Down Expand Up @@ -124,7 +126,7 @@ linter: testenv
%/chaintool: Makefile
@echo "Installing chaintool"
@mkdir -p $(@D)
curl -L https://github.com/hyperledger/fabric-chaintool/releases/download/$(CHAINTOOL_RELEASE)/chaintool > $@
curl -L $(CHAINTOOL_URL) > $@
chmod +x $@

# We (re)build a package within a docker context but persist the $GOPATH/pkg
Expand Down
50 changes: 23 additions & 27 deletions core/chaincode/platforms/car/test/car_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,34 @@ import (
"os"
"testing"

//"github.com/hyperledger/fabric/common/util"
"github.com/hyperledger/fabric/common/util"
"github.com/hyperledger/fabric/core/config"
//"github.com/hyperledger/fabric/core/container"
//pb "github.com/hyperledger/fabric/protos/peer"
"github.com/hyperledger/fabric/core/container"
pb "github.com/hyperledger/fabric/protos/peer"
)

func TestMain(m *testing.M) {
config.SetupTestConfig("../../../../../peer")
os.Exit(m.Run())
}

// Disable this for change chaincode interface temporarily.
// TODO: Update java chaincode interface and enable this.
//func TestCar_BuildImage(t *testing.T) {
// //Skipping the test till chaintool is fixed for changint CtorMsg to Input
// t.Skip()
// vm, err := container.NewVM()

// if err != nil {
// t.Errorf("Error getting VM: %s", err)
// return
// }
// // Build the spec
// cwd, err := os.Getwd()
// if err != nil {
// t.Errorf("Error getting CWD: %s", err)
// return
// }

// chaincodePath := cwd + "/org.hyperledger.chaincode.example02-0.1-SNAPSHOT.car"
// spec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_CAR, ChaincodeID: &pb.ChaincodeID{Name: "cartest", Path: chaincodePath}, Input: &pb.ChaincodeInput{Args: util.ToChaincodeArgs("f")}}
// if _, err := vm.BuildChaincodeContainer(spec); err != nil {
// t.Error(err)
// }
//}
func TestCar_BuildImage(t *testing.T) {
vm, err := container.NewVM()

if err != nil {
t.Errorf("Error getting VM: %s", err)
return
}
// Build the spec
cwd, err := os.Getwd()
if err != nil {
t.Errorf("Error getting CWD: %s", err)
return
}

chaincodePath := cwd + "/org.hyperledger.chaincode.example02-0.1-SNAPSHOT.car"
spec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_CAR, ChaincodeID: &pb.ChaincodeID{Name: "cartest", Path: chaincodePath}, Input: &pb.ChaincodeInput{Args: util.ToChaincodeArgs("f")}}
if _, err := vm.BuildChaincodeContainer(spec); err != nil {
t.Error(err)
}
}
Binary file not shown.

0 comments on commit cfa02a4

Please sign in to comment.