func TestCar_BuildImage(t *testing.T) { if os.Getenv("VAGRANT") == "" { t.Skip("skipping test; only supported within vagrant") } vm, err := container.NewVM() if err != nil { t.Fail() t.Logf("Error getting VM: %s", err) return } // Build the spec cwd, err := os.Getwd() if err != nil { t.Fail() t.Logf("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{Path: chaincodePath}, CtorMsg: &pb.ChaincodeInput{Function: "f"}} if _, err := vm.BuildChaincodeContainer(spec); err != nil { t.Fail() t.Log(err) } }
func sendLargeMsg(t testing.TB) (*pb.Message, error) { vm, err := container.NewVM() if err != nil { t.Fail() t.Logf("Error getting VM: %s", err) return nil, err } inputbuf, err := vm.GetPeerPackageBytes() if err != nil { t.Fail() t.Logf("Error Getting Peer package bytes: %s", err) return nil, err } payload, err := ioutil.ReadAll(inputbuf) return &pb.Message{Type: pb.Message_DISC_NEWMSG, Payload: payload}, nil }
func TestJava_BuildImage(t *testing.T) { vm, err := container.NewVM() if err != nil { t.Fail() t.Logf("Error getting VM: %s", err) return } chaincodePath := "../../../../../examples/chaincode/java/SimpleSample" //TODO find a better way to launch example java chaincode spec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_JAVA, ChaincodeID: &pb.ChaincodeID{Name: "ssample", Path: chaincodePath}, CtorMsg: &pb.ChaincodeInput{Args: util.ToChaincodeArgs("f")}} if _, err := vm.BuildChaincodeContainer(spec); err != nil { t.Fail() t.Log(err) } }
// Build builds the supplied chaincode image func (b *BDDContext) build(spec *pb.ChaincodeSpec) (*pb.ChaincodeDeploymentSpec, error) { var codePackageBytes []byte if err := b.checkSpec(spec); err != nil { return nil, err } vm, err := container.NewVM() if err != nil { return nil, fmt.Errorf("Error getting vm") } codePackageBytes, err = vm.BuildChaincodeContainer(spec) if err != nil { return nil, err } chaincodeDeploymentSpec := &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec, CodePackage: codePackageBytes} return chaincodeDeploymentSpec, nil }
func TestCar_BuildImage(t *testing.T) { vm, err := container.NewVM() if err != nil { t.Fail() t.Logf("Error getting VM: %s", err) return } // Build the spec cwd, err := os.Getwd() if err != nil { t.Fail() t.Logf("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{Path: chaincodePath}, CtorMsg: &pb.ChaincodeInput{Args: util.ToChaincodeArgs("f")}} if _, err := vm.BuildChaincodeContainer(spec); err != nil { t.Fail() t.Log(err) } }
// Build builds the supplied chaincode image func (*Devops) Build(context context.Context, spec *pb.ChaincodeSpec) (*pb.ChaincodeDeploymentSpec, error) { mode := viper.GetString("chaincode.mode") var codePackageBytes []byte if mode != chaincode.DevModeUserRunsChaincode { devopsLogger.Debugf("Received build request for chaincode spec: %v", spec) if err := CheckSpec(spec); err != nil { return nil, err } vm, err := container.NewVM() if err != nil { return nil, fmt.Errorf("Error getting vm") } codePackageBytes, err = vm.BuildChaincodeContainer(spec) if err != nil { devopsLogger.Error(fmt.Sprintf("%s", err)) return nil, err } } chaincodeDeploymentSpec := &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec, CodePackage: codePackageBytes} return chaincodeDeploymentSpec, nil }