i'm trying to use caliper hyperledger to evaluate a local network blockchain, it works correctly when i use the standard exemple simple.json that i found in this tuto:https://github.com/MarcoMazzoni/quorum-caliper-benchmarks but i want to applicate it on my smartcontract , so i start to test a simple smartcontract with only two functions addDrug(name,price,form, ref) and getDrug(ref),the workload file i used is like below i'm not sure on how it should be:

   /*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict';

module.exports.info = 'adding drugs';

let drugList = [];
let txnPerBatch=5;
let price=1025;
let ref=22;
let form= 'tablets';
let DrugName='adolp';

let bc, contx;
module.exports.init = function(blockchain, context, args) {

  bc = blockchain;
  contx = context;

  return Promise.resolve();
};

/**
 * Generates Users workload
 * @returns {Object} array of json objects
 */
function generateWorkload() {
  let workload = [];
  for (let i = 0; i < txnPerBatch; i++) {
  
    drugList.push(DrugName);

    if (bc.bcType === 'fabric') {
      workload.push({
        chaincodeFunction: 'addDrug',
        chaincodeArguments: [DrugName, price.toString()]
      });
    } else {
      //Quorum
      workload.push({
        verb: 'addDrug',
        args: [DrugName, price,form,ref],
        //isPrivate: contx.contracts['Users'].isPrivate,
        //privateFor: contx.contracts['Users'].privateFor
      });
    }
  }
  return workload;
}

module.exports.run = function() {
  let args = generateWorkload();
  return bc.invokeSmartContract(contx, 'Users', 'v0', args, 100);
};

module.exports.end = function() {
  return Promise.resolve();
};

module.exports.drugList = drugList;

i create a benchconfg file and a networkconfig file then run my benchmark, but i get 0 success transaction and an error msg :TypeError: Cannot read property 'contract' of undefined.

I'm a beginner with caliper trying to understand how it works..so thnx for any help with a tutorial or a helpfull link !

0

There are 0 best solutions below