Ejemplo n.º 1
0
func sendLargeMsg(t testing.TB) (*pb.OpenchainMessage, 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.OpenchainMessage{Type: pb.OpenchainMessage_DISC_NEWMSG, Payload: payload}, nil

}
Ejemplo n.º 2
0
// 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.Debug("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 {
			err = fmt.Errorf("Error getting chaincode package bytes: %s", err)
			devopsLogger.Error(fmt.Sprintf("%s", err))
			return nil, err
		}
	}
	chaincodeDeploymentSpec := &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec, CodePackage: codePackageBytes}
	return chaincodeDeploymentSpec, nil
}